【转】Nginx服务器详细配置含注释
2016-04-19 13:57
549 查看
#使用的用户和组 user www www; #指定工作衍生进程数(一般等于CPU的总核数或总核数的两倍) worker_processes 8; #指定错误日志存放的路径,错误日志的记录级别可为debug,info,notice,warn,error,crit error_log error.log crit; #指定pid文件存放的路径 pid nginx.pid; #指定文件描述符的数量 worker_rlimit_nofile 51200; events{ #使用的I/O模型,Linux系统推荐使用epoll模型,FreeBSD推荐使用kqueue模型 #在我的Mac OSX 11系统中报错 invalid event type "kueue" #use kueue; #允许连接数 worker_connections 51200; } http{ #根据自己的文件目录,配置mime.types文件路径 #include path/to/mime.types; default_type application/octet-stream; #设置使用的字符集,如果一个网站有多种字符集,请不要随便设置,应让程序员在HTML代码中通过meta标签进行设置 #charset gb2312; #日志格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' ' "$http_user_agent" $http_x_forwarded_for '; #日志级别,访问日志 access_log access.log main; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; #设置客户端能够上传的文件大小 client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 61k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; #开启gzip压缩 gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #limit_zone crawler $binary_remote_addr 10m; server{ listen 80; server_name www.yourdomain.com yourdomain.com; index index.html index.htm index.php; root /path/to/root; #limit_conn crawler 20; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } } }
转载于:http://www.siguoya.name/home/article/41
相关文章推荐
- 配置Nginx多核CPU,worker_cpu_affinity使用方法和范例
- CentOS 安装和启动nginx
- yaf框架官方手册nginx配置错误
- nginx下多项目跨域ajax实现
- Nginx动静分离知识及配置
- RHEL/CentOS and Debian/Ubuntu上使用Nginx安装odoo9
- studyphp环境软件Nginx隐藏index.php和Pathinfo模式配置例子
- Nginx根据不同浏览器语言配置页面跳转的方法
- studyphp环境软件Nginx隐藏index.php和Pathinfo模式配置例子
- nginx reload 命令报:nginx: [error] invalid PID number
- PPA方式升级Nginx
- nginx设置不使用缓存 add_header Cache-Control no-cache
- nginx配置入门
- Nginx重新编译添加模块
- centos7 nginx permission denied while connecting to upstream
- 网站设置404页面 --nginx
- 初实nginx服务器配置之文件目录
- nginx日志配置指令详解
- Nginx_查看并发连接数
- Nginx教程(一) Nginx入门教程