nginxconf配置說明

來源:互聯網
上載者:User
1:nginx.conf檔案內容如下:

worker_processes 4; //指4核cpu

events {
worker_connections 65535; //linux 下ulimit -n查看參數匹配
}


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"';

sendfile on;//傳輸檔案加速
keepalive_timeout 30;//訪問網站等待時間

client_max_body_size 6m;//最大上傳檔案大小

gzip on;//文字檔壓縮傳輸

include /opt/nginx/conf/vhost/*;//包括多個配置的網站,下面舉例:b2b.conf和auto.conf
}

2:b2b.conf檔案內容如下:

server {
listen 80;
server_name www.b2bxxx.cn b2bxxx.cn ;

location / {//網站首頁
root /opt/huahuionline;
index index.html index.htm;
}

location ^~ /static/ {//靜態檔案
root /opt;
}

location ~ .*$ {
proxy_pass http://127.0.0.1:22; //動態程式跳轉
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|mp4)$ {
expires 60d;//緩衝60天
}

location ~ .*\.(js|css)?$ {
expires 3h;//緩衝3小時
}
location ~ .*\.(html)?$ {
expires 5m;//緩衝5分鐘
}

access_log /opt/nginx/logs/b2b.log; //預設 access.log
error_log /opt/nginx/logs/b2b_err.log;//預設error.log
}

3:auto.conf 內容如下:

server {
listen 80;
server_name www.autodesign.club autodesign.club;

location ^~ /auto_static/ {
root /opt;
}

location ~ .*$ {
proxy_pass http://127.0.0.1:33; //連接埠和上面的不一樣
rewrite ^/$ /MainCtrl?page=IndexPage last; //首頁跳轉
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|mp4)$ {
expires 60d;
}

location ~ .*\.(js|css)?$ {
expires 3h;
}

access_log /opt/nginx/logs/auto.log;
error_log /opt/nginx/logs/auto_err.log;

}

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

以上就介紹了nginxconf配置說明,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.