nginx配置

安裝完nginx后,在安裝目錄下的conf下面找到nginx的配置文件nginx.conf文件。

#Nginx的worker進(jìn)程運(yùn)行的用戶及用戶組
#user  nobody;

#Nginx開(kāi)啟的進(jìn)程數(shù)
worker_processes  1;

#定義全局錯(cuò)誤日志定義類型,[debug|info|notice|warn|crit]
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#指定進(jìn)程ID存儲(chǔ)文件位置
#pid        logs/nginx.pid;

#----------------------------------------------
#事件配置
events {
    #注意:最大客戶數(shù)也由系統(tǒng)的可用socket連接數(shù)限制(~64K),所以設(shè)置不切實(shí)際的高沒(méi)什么好處
    worker_connections  1024;
}

#----------------------------------------------
#http參數(shù)
http {
    #文件擴(kuò)展名與文件類型映射表,在配置文件同級(jí)目錄下的mime.types文件
    include       mime.types;
    #默認(rèn)文件類型
    default_type  application/octet-stream;

    # 日志相關(guān)定義
    #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;

    #開(kāi)啟高速傳輸模式
    sendfile        on;
    #tcp_nopush     on;

    #客戶端連接超時(shí)時(shí)間,單位是秒
    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    #----------------------虛擬主機(jī)------------------------
    server {
        #監(jiān)聽(tīng)端口號(hào)
        listen       8080;
        #訪問(wèn)域名
        server_name  localhost;

        #編碼格式,,若網(wǎng)頁(yè)格式與此不同,將被自動(dòng)轉(zhuǎn)碼
        #charset koi8-r;

        #虛擬主機(jī)訪問(wèn)日志定義
        #access_log  logs/host.access.log  main;

        #對(duì)URL進(jìn)行匹配
        location / {
            #訪問(wèn)路徑,可相對(duì)也可絕對(duì)路徑
            root   html;
             #首頁(yè)文件。以下按順序匹配
            index  index.html index.htm;
        # proxy_pass http://localhost;
        }

#錯(cuò)誤信息返回頁(yè)面
        #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;
        }

#訪問(wèn)URL以.php結(jié)尾則自動(dòng)轉(zhuǎn)交給127.0.0.1
        # 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;
        #}

#禁止訪問(wèn).ht頁(yè)面 (需ngx_http_access_module模塊)
        # 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虛擬主機(jī)定義
    # 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)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容