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教程有興趣的朋友有所協助。