1. Open nginx configuration file nginx.conf, you can find its initial content as follows:
#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; Proxy_pass http://192.168.56.202:8080; } #error_page 404/404.html; # REDIRECT Server error pages to the Static page/50x.html # Error_page 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$ {# ProX Y_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 # #l ocation ~/\.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; # } #}}
The simple point can be understood as a few blocks:
... #全局块events #event block {...} Http#http Block {... #http全局块}server#server block {... #server全局块location [PATTERN] #location块 {...} Location [PATTERN] #location块 {...}} Server#server Block {...} ...}
2. The role of each block
Global blocks: The primary setting is the configuration that affects the overall operation of the server, and its scope is global. Typically includes servers
User, the worker process allowed to be generated (this configuration item is typically the number of cores for the server host), and the Nginx process PID
The storage path, log storage path and type, and the introduction of the configuration file
Events BLOCK: Mainly set some parameters affecting the server and the user's network link, commonly used are: whether to open the
The network connection under multi-worker process is serialized, the master allows to receive multiple network connections at the same time, each
The maximum number of connections that worker process can support at the same time.
HTTP BLOCK: General configuration agent, cache, log definition, and so on how much of the features and third-party configuration are set in this module
Server block: Related to Virtual host
Location BLOCK: Processing of requests, address orientation, response control
The above introduces the initial knowledge of Nginx configuration file--nginxconf, including Nginx, configuration file aspects of the content, I hope that the PHP tutorial interested in a friend helpful.