nginx (1): nginx 기본 설정 및 매개 변수 설정

3173 단어 nginx배치 하 다.
#    
user nobody;
#    ,      cpu     
worker_processes  1;

#       PID  
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

#          
events {
    #epoll     IO(I/O Multiplexing)      ,
    #   linux2.6    ,      nginx   
    use   epoll; 

    #    worker process              
    worker_connections  1024;

    #       worker_processes   worker_connections    
    #   max_clients = worker_processes * worker_connections
    #             ,max_clients = worker_processes * worker_connections / 4     
    #             4,         
    #       ,      Nginx Server           :4 * 8000 = 32000
    # worker_connections              
    #      IO  ,max_clients                 
    #                      ,  1GB                 10   
    #      360M   VPS             :
    # $ cat /proc/sys/fs/file-max
    #    34336
    # 32000 < 34336,                      ,                 
    #   ,worker_connections       worker_processes                            
    #                        
    #              CPU       
    #   ,                  ,                     。
    # ulimit -SHn 65535

}


http {
    #  mime  ,   mime.type    
    include    mime.types;
    default_type  application/octet-stream;
    #      
    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  logs/access.log  main;

    #sendfile      nginx      sendfile   (zero copy   )     ,
    #      ,     on,
    #             IO     ,     off,
    #        I/O    ,     uptime.
    sendfile     on;
    #tcp_nopush     on;

    #      
    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay     on;

    #  gzip  
    gzip  on;
    gzip_disable "MSIE [1-6].";

    #      
    client_header_buffer_size    128k;
    large_client_header_buffers  4 128k;


    #        
    server {
        #  80  
        listen    80;
        #     www.nginx.cn  
        server_name  www.nginx.cn;

        #               
        root html;

        #            
        access_log  logs/nginx.access.log  main;

        #    
        location / {
            
            #           
            index index.php index.html index.htm;   

        }

        #         
        error_page   500 502 503 504 /50x.html;
        location = /50x.html {
        }

        #    ,nginx    
        location ~ ^/(images|javascript|js|css|flash|media|static)/ {
            
            #  30 ,         ,        ,
            #      ,         。
            expires 30d;
        }

        #PHP           FastCGI  .   FastCGI    .
        location ~ .php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

        #     .htxxx   
            location ~ /.ht {
            deny all;
        }

    }
}

좋은 웹페이지 즐겨찾기