nginx設定檔詳細教程,nginx設定檔

來源:互聯網
上載者:User

nginx設定檔詳細教程,nginx設定檔

nginx設定檔詳細教程

Nginx設定檔位於nginx目錄下的conf檔案夾下,為nginx.conf,下面簡單介紹下設定檔中各項的含義,一入nginx深似海,功能非常強大,同時也非常複雜。

全域配置:

user nobody; #運行使用者worker_processes 1; #表示背景工作處理序的數量,通常設定成和CPU的數量相等全域錯誤記錄檔以及pid檔案#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;
Events模組:
events {    worker_connections  1024; #單個後台worker process進程的最大並發串連數}

http模組:

http {    include       mime.types; #設定mime類型,類型由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; #指令指定nginx是否調用sendfile函數來輸出檔案    #tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout  65; #連線逾時時間    #gzip  on; #開啟gzip壓縮    autoindex on; #設定顯示項目目錄      #設定虛擬機器主機配置 server {     listen       80; #監聽80連接埠     server_name  demo.shop.cn; #設定訪問網域名稱     root html; #定義伺服器的預設項目根目錄     #charset koi8-r;     #access_log  logs/host.access.log  main; #設定本虛擬機器主機的預設訪問日誌          #預設請求        location / {            root   html;            index  index.php 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   https://127.0.0.1;        #}        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #PHP指令碼請求全部轉寄到FastCGI處理,使用FastCGI預設配置        location ~ \.php$ {            root           html;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root$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;        #}    }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.