nginx配置詳解---學校資料

#配置worker進程運行用戶 nobody也是一個linux用戶,通常用於啓動程序,沒有密碼
user  nobody;  
#配置工做進程數目,根據硬件調整,一般等於CPU數量或者2倍於CPU數量
worker_processes  1;  

#配置全局錯誤日誌及類型,[debug | info | notice | warn | error | crit],默認是error
error_log  logs/error.log;  
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;  #配置進程pid文件 


###====================================================


#配置工做模式和鏈接數
events {
    worker_connections  1024;  #配置每一個worker進程鏈接數上限,nginx支持的總鏈接數就等於worker_processes * worker_connections
}

###===================================================


#配置http服務器,利用它的反向代理功能提供負載均衡支持
http {
    #配置nginx支持哪些多媒體類型,能夠在conf/mime.types查看支持哪些多媒體類型
    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日誌及存放路徑,並使用上面定義的main日誌格式
    #access_log  logs/access.log  main;

    sendfile        on;  #開啓高效文件傳輸模式
    #tcp_nopush     on;  #防止網絡阻塞

    #keepalive_timeout  0;
    keepalive_timeout  65;  #長鏈接超時時間,單位是秒

    #gzip  on;  #開啓gzip壓縮輸出
    
    ###-----------------------------------------------
    

    #配置虛擬主機
    server {
        listen       80;  #配置監聽端口
        server_name  localhost;  #配置服務名

        #charset koi8-r;  #配置字符集

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

    #默認的匹配斜槓/的請求,當訪問路徑中有斜槓/,會被該location匹配到並進行處理
        location / {
        #root是配置服務器的默認網站根目錄位置,默認爲nginx安裝主目錄下的html目錄
            root   html;  
        #配置首頁文件的名稱
            index  index.html index.htm;  
        }        

        #error_page  404              /404.html;  #配置404頁面
        # redirect server error pages to the static page /50x.html
        #error_page   500 502 503 504  /50x.html;  #配置50x錯誤頁面
        
    #精確匹配
    location = /50x.html {
            root   html;
        }

        #PHP 腳本請求所有轉發到Apache處理
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        #PHP 腳本請求所有轉發到FastCGI處理
        # 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;
        #}

        #禁止訪問 .htaccess 文件
        # 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服務,安全的網絡傳輸協議,加密傳輸,端口443,運維來配置
    #
    # 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;
    #    }
    #}
}
相關文章
相關標籤/搜索