Nginx配置文件詳解

# 配置可啟動(dòng)nginx的用戶
#user  user [group];
#不限制用戶則可注釋user行,或像如下配置:
#user nobody nobody;
#user  nobody;

#配置nginx工作進(jìn)程數(shù),一般與cpu核數(shù)相同
#worker_processes  number | auto;
worker_processes  1;

#配置錯(cuò)誤日志存放路徑及錯(cuò)誤日志輸出級(jí)別(debug,info,notice,warn,error,crit,alert,emerg)
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#配置pid存放路徑
#pid        logs/nginx.pid;

#引入其他配置文件,file支持相對(duì)路徑
#include file;

events {
    #開啟nginx進(jìn)程接收鏈接序列化,防止多個(gè)進(jìn)程對(duì)連接的爭(zhēng)搶。默認(rèn)為on。只能配置在events中
    #accept_mutex on | off;
    #配置是否開啟每個(gè)work process同時(shí)接收多個(gè)新到達(dá)的網(wǎng)絡(luò)連接,默認(rèn)為off。只能配置在events中
    #multi_accept on | off;
    #配置強(qiáng)制使用某種事件驅(qū)動(dòng)模型來處理網(wǎng)絡(luò)消息。method包括:select,poll,kqueue,epoll,rtsig,/dev/poll,eventport。只能配置在events中
    #use method;
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #服務(wù)日志可是定義,只能在http塊中配置
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #服務(wù)日志存放路徑定義
    #access_log  logs/access.log  main;

    #用于開啟或關(guān)閉使用sendfile()傳輸文件
    sendfile        on;
    #配置每個(gè)work process每次調(diào)用sendfile()傳輸?shù)臄?shù)據(jù)量最大值;若為0則不限制
    #sendfile_max_chunk size;
    #tcp_nopush     on;

    #配置nginx與用戶建立連接會(huì)話后,nginx保持這個(gè)連接打開的一段時(shí)間(單位s)
    #keepalive_timeout  timeout[ header_timeout];
    keepalive_timeout  65;
    #該指令用于限制用戶通過某一連接向nginx服務(wù)器發(fā)送請(qǐng)求的次數(shù)
    #keepalive_requests number;

    #gzip  on;

    server {
        #設(shè)置監(jiān)聽IP與端口
        #監(jiān)聽所有IP的80和8000端口
        #listen *:80 | *:8000;
        listen       80;
        #配置虛擬主機(jī)名稱
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            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$ {
        #    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;
    #    }
    #}

}


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • 轉(zhuǎn)自 : http://www.cnblogs.com/hunttown/p/5759959.html
    Real_young閱讀 256評(píng)論 0 0
  • 參考nginx配置文件詳解中文版本文列出了nginx默認(rèn)配置文件 nginx.conf的大部分命令,并加以中文注釋...
    云龍789閱讀 13,836評(píng)論 2 8
  • 1、nginx配置概覽 概覽 一個(gè)典型的nginx配置文件是由一系列的server塊組成。而每個(gè)server塊是有...
    st0rm23閱讀 2,140評(píng)論 0 0
  • ######Nginx配置文件nginx.conf中文詳解##### #定義Nginx運(yùn)行的用戶和用戶組 user...
    憶飛閱讀 783評(píng)論 0 0
  • 配置文件詳解 upstream 配置詳解 輪詢(默認(rèn)) 每個(gè)請(qǐng)求按時(shí)間順序逐一分配到不同的后端服務(wù)器,如果后端服務(wù)...
    陳小陌丿閱讀 896評(píng)論 0 0