Nginx配置文件詳解

#user  nobody;    登陸用戶php

worker_processes  1;   nginx開啓的進程數,通常開啓一個就足夠,多開幾個work進程,能夠減小機器io帶來的影響,在通常狀況下html

開啓4個或者8個,多開無心nginx

 

#error_log  logs/error.log;  錯誤日誌目錄服務器

#error_log  logs/error.log  notice;session

#error_log  logs/error.log  info;併發

 

#pid        logs/nginx.pid;   記錄nginx pid文件的參數app

 

 

events {  每一個work進程能夠處理的鏈接數 併發鏈接數tcp

    worker_connections  1024;  若是網站訪問量過大,已經超過1024併發數,那麼就要修改worker_connecions,這個植越大ide

併發數也就大,按照實際狀況決定,不能設置過多,不然會形成IO負載量過大網站

}

 

 

http {

    include       mime.types;  爲文件類型定義文件

    default_type  application/octet-stream; 默認文件類型

 

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

 

    #access_log  logs/access.log  main;  建立訪問日誌

 

    sendfile        on;

    #tcp_nopush     on;  開啓後會產生一個響應頭部信息產生獨立的數據包發送,一個響應頭一個包

 

    #keepalive_timeout  0;  保持鏈接的超時時間

    keepalive_timeout  65;

 

    #gzip  on; 是否採用壓縮

    server {

        listen  80;

        server_name     www.xiaohu.com;

        location / {

        root    html/xiaohu;

        index   index.html  index.htm;

}

}

    server {  定義虛擬機

        listen       80;  服務器監聽端口

        server_name  localhost;  訪問域名

 

        #charset koi8-r;  編碼格式

 

        #access_log  logs/host.access.log  main;  虛擬主機訪問日誌

 

        location / {  url匹配

            root   html;  網頁路徑

            index  index.html index.htm;  首頁文件

        }

 

        #error_page  404              /404.html;

 

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

 

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {  php頁面

        #    proxy_pass   http://127.0.0.1;   反向代理模塊  反向代理地址

        #}

 

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}

 

        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }

 

 

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

 

    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;

 

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

 

    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;

 

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

}

相關文章
相關標籤/搜索