Location and profile of the part to explain the structure Nginx

Scenes

Ubuntu Server 16.04 LTS on how to install and start the download and install Nginx:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/102828075

After installing the Nginx above, there is a conf directory under / usr / local / nginx /, has at nginx.conf conf directory,

This is the Nginx configuration file.

Note:

Blog:
https://blog.csdn.net/badao_liumang_qizhi
public concern number of
programs overbearing ape
acquisition-related programming e-books, tutorials and push for free download.

achieve

You can download the configuration file

sz nginx.conf

 

 

Get into edit mode View Profile

force nginx.conf

 

 

Profile content

 

#user  nobody;
worker_processes  1;

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

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    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        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /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;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # 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;
    #    }
    #}

}

 

Profiles of each part

nginx.conf configuration file is divided into three parts:

Part I: global block

  Starting profile content between blocks of events, some of the main part is provided affect the overall operation of the server nginx configuration instructions, including the user profile server running Nginx (group), the number of worker process allows generation, process PID storage path, the log and the introduction of other types of storage paths, and configuration file. The above configuration such as the first line of:

worker_processes  1;

 

  This is the key to configure Nginx server concurrent processing services, worker_processes greater the value, the amount of concurrent processing can also support more, but will be constrained by hardware, software and other equipment

Second part: events block

For example, the above

events {
    worker_connections  1024;
}

  events main block instruction according to the user's influence Nginx server network connection, including whether to enable common setting in a multi-network connection sequence of work process, is allowed to simultaneously receive a plurality of network connections, which handle event-driven model to select a connection request, each word process can support the maximum number of simultaneous connections and the like. Each of the above examples to represent the maximum number of supported work process connection 1024. The configuration of this part a greater impact on the performance of Nginx in practice should be flexible configuration.

Part III: http block

 

 

  This is regarded as the most frequently Nginx server configuration part, configure the proxy, caching and logging functions and definitions vast majority of third-party modules are all here. Note that: http blocks may also include http global block, server block.

1.http global block

  Http global block configuration instruction file includes introducing, MIME-TYPE is defined, custom logging, connection time, etc. The maximum number of single link request.

2.server block

  And this is closely related to web hosting, web hosting from the user point of view, and a separate host hardware is exactly the same, the technology is generated in order to save the Internet server hardware costs. Each block http server may include a plurality of blocks, and each block is equivalent to a virtual server host. Server and each block is also divided into blocks of a global server, and may comprise a plurality of blocks simultaneously locaton.

(1) global server block

  The most common configuration is to monitor and configure this virtual host name or IP configuration of this virtual machine host.

(2) location block

  Server may be configured to block a plurality of blocks location. This main function is to request string (e.g. server_name / uri-string) Nginx server based on the received character string (e.g., the preceding / uri-string) beyond the virtual host name (IP alias may be) of matching, the processing of a particular request. Address directional, data caching and response control functions, there are many third-party modules are configured here.

Guess you like

Origin www.cnblogs.com/badaoliumangqizhi/p/11768875.html