nginx 配置 详解(待指点/更新)

来源:互联网 发布:美工抠图总结 编辑:程序博客网 时间:2024/05/01 14:35
#运行用户user  www www;#启动进程,通常设置为和cpu数量相等worker_processes 1;#错误日志error_log  /home/wwwlogs/nginx_error.log  crit;#PID文件pid        /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.worker_rlimit_nofile 51200;#工作模式及连接数上限events        {                use epoll;#epoll是多路复用IO(IO multiplexing)中的一种,适用于linux2.6内核以上,可以大大提升nginx性能                worker_connections 51200;#单个后台worker process进程的最大并发连接数        }#设定http服务器,利用他的反向代理功能提供负载均衡支持http        {                #设定mine类型,由mine.types文件定义                include       mime.types;#默认mine类型                default_type  application/octet-stream;#设定日志格式access_log /usr/local/nginx/logs/access.log                server_names_hash_bucket_size 128;#设定请求缓冲                client_header_buffer_size 32k;                large_client_header_buffers 4 32k;                client_max_body_size 50m;#sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,对于普通应用,    #必须设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络I/O处理速度,降低系统的uptime.                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 64k;                fastcgi_buffers 4 64k;                fastcgi_busy_buffers_size 128k;                fastcgi_temp_file_write_size 256k;#gzip开启                gzip on;                gzip_min_length  1k;                gzip_buffers     4 16k;                gzip_http_version 1.0;                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;                #log format                log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '             '$status $body_bytes_sent "$http_referer" '             '"$http_user_agent" $http_x_forwarded_for';    #设定负载均衡的服务器列表     #upstream mysvr {    #weigth参数表示权值,权值越高被分配到的几率越大    #本机上的Squid开启3128端口    #server 192.168.8.1:3128 weight=5;    #server 192.168.8.2:80  weight=1;    #server 192.168.8.3:80  weight=6;    }server        {#监听端口                listen       80;#定义使用www.dylan.com来访问                server_name www.dylan.com;#定义首页所以文件的名称                index index.html index.htm index.php;#定义本虚拟主机的默认网站根目录位置                root  /home/wwwroot;#php 请求用fastcgi处理                location ~ .*\.(php|php5)?$                        {                                try_files $uri =404;                                fastcgi_pass  unix:/tmp/php-cgi.sock;                                fastcgi_index index.php;                                include fcgi.conf;                        }#设定查看nginx状态的地址                location /status {                        stub_status on;                        access_log   off;                }                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$                        {                                expires      30d;                        }                location ~ .*\.(js|css)?$                        {                                expires      12h;                        }#设定本虚拟主机的访问日志                access_log  /home/wwwlogs/access.log  access;        }


原创粉丝点击