Nginx配置文件詳解

user www www;
#定義Nginx運行的用戶及組
worker_processes 8;
#進程數,通常是配置爲小於CPU數。
#[ debug | info | notice | warn | error | crit ]
error_log /data1/logs/nginx_error.log crit;
#錯誤日誌定義類型
pid /usr/local/webserver/nginx/nginx.pid;
#進程文件
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
#一個nginx進程打開的最多文件描述符數目,理論值應該是最多打開文件數(ulimit -n)與nginx進程數相除,可是nginx分配請求並非那麼均勻,因此最好與ulimit -n的值保持一致。
# use [ kqueue | rtsig | epoll | /dev/poll | select | poll ];
events
{
use epoll; #參考事件模型
worker_connections 65535; #每一個進程最大鏈接數(最大鏈接=鏈接數x進程數)
}
#設定http服務器
http
{
include mime.types; #文件擴展名與文件類型映射表
default_type application/octet-stream; #默認文件類型
#charset gb2312; #默認編碼
server_names_hash_bucket_size 128; #服務器名字的hash表大小
client_header_buffer_size 32k; #上傳文件大小限制
large_client_header_buffers 4 32k; #設定請求緩
client_max_body_size 8m; #設定請求緩
sendfile on; #開啓高效文件傳輸模式
tcp_nopush on; #防止網絡阻塞
tcp_nodelay on; #防止網絡阻塞
keepalive_timeout 60; #超時時間

#FastCGI是爲了改善網站的性能--減小資源佔用,提升訪問速度.有關fastCGI的詳細資料請參閱:http://www.fastcgi.com
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;javascript

gzip on;
gzip_min_length 1k; #最小壓縮文件大小
gzip_buffers 4 16k; #壓縮緩衝區
gzip_http_version 1.0; #壓縮版本(默認1.1,前端爲squid2.5使用1.0
gzip_comp_level 2; #壓縮等級
gzip_types text/plain application/x-javascript text/css application/xml;
#壓縮類型,默認就已經包含text/html 因此下面就不用再寫了,固然寫上去的話,也不會有問題,可是會有一個warn
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m; #開啓限制IP鏈接數的時候須要使用
#虛擬主機的配置
server
{
listen 80;
server_name www.opendoc.com.cn
index index.html index.htm index.php;
root /data0/htdocs/opendoc;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
#對圖片緩存
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
#對JS CSS 緩存
location ~ .*\.(js|css)?$
{
expires 1h;
}
#日誌設定
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /data1/logs/access.log access;
}
}php

相關文章
相關標籤/搜索