[] Nginx Nginx configuration file parsing


The default configuration file path: / usr / local / nginx / conf

The main configuration file: /usr/local/nginx/conf/nginx.conf

The main configuration file required frame (nginx.conf) profile is the end of each sentence must have a semicolon;, braces must be paired

#user nobody; what a user to run nginx 
worker_processes   1 ; open several processes, the process to open according to the number of CPU core, and can not fill out any 

#error_log logs / error.log; 
#error_log logs / error.log Notice; 
#error_log logs /error.log   info ; 

# PID logs / nginx.pid; Nginx PID storage location, / usr / local / Nginx / logs / nginx.pid 


Events { 
    worker_connections   1024 ; concurrent, the default is 1024, and the number of concurrent kernel parameters related , 1024 is the default kernel parameters openfile memory parameter limits the number of concurrent 
} 


HTTP {website 
    the include the mime.types; 
    default_type file application / OCTET - Uninterpreted Stream; 

    #log_format main   'REMOTE_ADDR $ - $ REMOTE_USER [$ time_local] "$ Request" 'log log recording format, the default is best not to modify the 
    #                   ' $ Status $ body_bytes_sent "$ HTTP_REFERER" ' 
    #                   ' "$ HTTP_USER_AGENT" "$ HTTP_X_FORWARDED_FOR" ' ; 

    #access_log logs / the access.log main; access log location access_log 

    the sendfile ON; 
    #tcp_nopush ON; 

    #keepalive_timeout   0 ; 
    keepalive_timeout   65 ; 

    # the gzip   ON;Page compression 

    server {a server {} is a web service, if no configuration file inside the server {}, then start nginx is unable to access the web page 
        the listen        80; Listening port, the default 80 
        server_name localhost; domain 

        #charset KOI8 - R & lt; 

        #access_log logs / host.access.log main; 

        LOCATION / {path match, access of http://127.0.0.1 / a when this configuration is to match the LOCATION / {}, matched to the return location / {} braces inside the content, a server {} have a plurality of location {}; Similarly, in the address bar matches http://127.0.0.0/test configuration file inside LOCATION / Test {} 
            the root HTML; HTML pages in the directory, the installation path / usr / local / Nginx / HTML 
            index index.html index.htm; default home page, access http://127.0.0.1/ is when the page returned 
        } 

        #error_page   404               / 404.html; error page can be customized error page 

        # to the redirect Server Pages The static error Page / 50x.html 
        # 
        error_page    500  502  503  504   / 50x.html; error page 
        LOCATION = / 50x.html { 
            the root HTML; 
        } 

        # Proxy Listening to the Apache the PHP scripts The ON 127.0 . 0.1 : 80 
        # 
        #location ~ \ .php $ { 
        # proxy_pass HTTP: // 127.0.0.1; 
        #} 

        # Pass the PHP scripts The ON Listening to the FastCGI Server127.0 . 0.1 : 9000 
        # 
        #location ~ \ .php $ {matches the end of the dynamic page .php 
        # root html; dynamic page position 
        # fastcgi_pass    127.0 . 0.1 : 9000 ; when forwarding matched to the 9000 port of the machine to process 
        # fastcgi_index index.php; default home 
        # fastcgi_param SCRIPT_FILENAME   / scripts $ fastcgi_script_name; 
        # the include fastcgi.conf; external loading profile 
        #} 

        # .htaccess the deny Access to files, IF the Apache ' S the root document 
        # concurs with Nginx 'One S 
        # 
        #location ~ / \ .ht { 
        # All the deny; 
        #} 
    } 


    # Another Virtual Host Mix the using of the IP -, name-, and port- based Configuration 
    # 
    #server {a server {} is a web service, where the server is a virtual server 
    # the listen        8000 ;     
    # the listen somename: 8080 ; 
    # server_name somename Alias another.alias; 

    # LOCATION / { 
    # the root HTML; 
    # index index.html index.htm; 
    #} 
    #} 


    # the HTTPS server 
    #
    {#server     
    # the listen        443 ssl; encrypted site HTTPS, 443 port 
    # server_name localhost; 

    # ssl_certificate cert.pem; the public key certificate file name, do not write the default path is / usr / loca / nginx / conf / directory 
    # ssl_certificate_key cert.key; private key 

    # ssl_session_cache Shared: SSL: 1M; 
    # ssl_session_timeout 5m; 

    # ssl_ciphers HIGH: ! aNULL :! MD5; 
    # ssl_prefer_server_ciphers ON; 

    # LOCATION / { 
    # root HTML; page catalog 
    # index index.html index.htm ; Home page 
    #} 
    #} 

}

Guess you like

Origin www.cnblogs.com/BadManWM/p/12182449.html