手机版
你好,游客 登录 注册
背景:
阅读新闻

一些Nginx的高级扩展应用总结

[日期:2013-04-02] 来源:Linux社区  作者:rfyiamcool [字体: ]

nginx.conf 配置解释

详解user  www www;
定义 Nginx 运行的用户及组
worker_processes 8; #[ 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; server listen  80;
server_name www.linuxidc.com
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;
}

linux
相关资讯       Nginx  Nginx扩展 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款