| 关键词: FastCGI 文件 进程 Nginx http gzip index size buffers timeout |
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; 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; } } |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|