nginx配置文件详解(优化)
来源:互联网 发布:$.each数组变化 编辑:程序博客网 时间:2024/06/06 03:36
#user nobody; #运行nginx的用户
worker_processes1;#于服务器核心数相同
worker_rlimit_nofile100000;#nginx进程打开的最多文件描述符数目,ulimit -n相同
#error_log logs/ .log; #各种日志放哪里
#error_log logs/ .log notice;
#error_log logs/ .log info;
pid logs/nginx.pid;#pid文件
events{ #Nginx事件处理模型
worker_connections10000;#单个worker进程允许客户端最大连接数
multi_accepton;#一次accept一个新连接,or 一次accept所有的新连接
useepoll;#nginx采用epoll事件模型,处理效率高
}
http{
include mime.types;#媒体类型,include 只是一个在当前文件中包含另一个文件内容的指令
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] '
# '$status $body_bytes_sent '
# ' ';
#access_log logs/access.log main;
server_tokensoff;
error_logerror.logcrit;
sendfileon;#开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。如果图片显示不正常把这个改成off。
tcp_nopushon;#必须在sendfile开启模式才有效,防止网路阻塞,积极的减少网络报文段的数量(将响应头和正文的开始部分一起发送,而不一个接一个的发送。)
tcp_nodelayon;#必须在sendfile开启模式才有效,防止网路阻塞,积极的减少网络报文段的数量(将响应头和正文的开始部分一起发送,而不一个接一个的发送。)
keepalive_timeout60;#客户端连接保持会话超时时间,超过这个时间,服务器断开这个链接
client_header_timeout10;#设置请求头的超时时间。我们也可以把这个设置低些,如果超过这个时间没有发送任何数据,nginx将返回request time out的错误
client_body_timeout10;#设置请求体的超时时间。我们也可以把这个设置低些,超过这个时间没有发送任何数据,和上面一样的错误提示
reset_timedout_connectionon;#告诉nginx关闭不响应的客户端连接。这将会释放那个客户端所占有的内存空间。
send_timeout10;#响应客户端超时时间,这个超时时间仅限于两个活动之间的时间,如果超过这个时间,客户端没有任何活动,nginx关闭连接
#default_type text/html;
charset UTF-8;
gzipon;#开启页面压缩
gzip_disable"msie6";
gzip_proxied any;
gzip_min_length1000;
gzip_comp_level6;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
open_file_cache max=100000 inactive=20s;#这个将为打开文件指定缓存,默认是没有启用的,max指定缓存数量,建议和打开文件
数一致,inactive是指经过多长时间文件没被请求后删除缓存。
open_file_cache_valid30s;#这个是指多长时间检查一次缓存的有效信息。
open_file_cache_min_uses2;#open_file_cache指令中的inactive 参数时间内文件的最少使用次数,如果超过这个数字,文
件描述符一直是在缓存中打开的,如上例,如果有一个文件在inactive时间内一次没被使用,它将被移除。
open_file_cache_errorsoff;
server{ #主机字段
listen80;#监听端口
server_namewww.zjswdlt.cn;#域名
#charset koi8-r;
#access_log logs/host.access.log main;
location/ {
root html; #页面所在目录
indexindex.htmlindex.htmindex.php;#首页文件
}
#error_page 404 /404.html; #404页面
# redirect server error pages to the static page /50x.html
#
error_page500502503504/50x.html;
location= /50x.html{
root html;
}
#proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
#passthe PHP scripts to FastCGI server listening on 127.0.0.1:9000
location~ \.php${ #打开php解析
root html/bbs;#php页面地址
fastcgi_pass127.0.0.1:9000;#启用端口
fastcgi_indexindex.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
#index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
#index index.html index.htm;
# }
#}
}
阅读全文
0 0
- nginx配置文件详解(优化)
- Nginx配置文件优化实例与参数详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件nginx.conf详解(总结)
- Nginx配置文件(nginx.conf)配置详解
- nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- Nginx配置文件(nginx.conf)配置详解
- CSS 居中
- LTE下行物理层传输机制(1)-天线端口Antenna Port和小区特定参考信号CRS
- TensorFlow学习笔记1
- leetcode17-根据数字找到可能的按键字母组合
- 文件及数据流技术(二)
- nginx配置文件详解(优化)
- php 定义和引用变量 (一)
- js 对table 表单操作总结
- 解决table边框圆角无效
- 关于python列表去重复后按照元列表序列输出
- 基于CH376的U盘读写
- Vintage分析和迁移率模型在信用卡业务中的应用
- MySql常用查询语句(23种)
- 设置build.xml将项目打包