Nginx is an open source software that supports high concurrency and is fairly lightweight to handle static resources.
It also supports a variety of modules for function expansion, although nginx cannot handle dynamic resources by itself, but it can realize the function of dynamic resources through fastcgi module.
**nginx_http_fastcgi_module Module Configuration * *
Address for fastcgi server fastcgi_pass;
Fasgcgi_index name; Defines the default home page for fastcgi apps;
Fastcgi_param parameter value; Sets the parameters and values passed to the backend fastcgi server;
Fastcgi_cache_path path [levels=levels] [Use_temp_path=on|off] keys_zone=name:size [Inactive=time] [max_size=size]; Defines the caching mechanism, application context: HTTP
Caching mechanism:
Meta Data:
Data: disk, which is path;
Meta data: Memory, that is, keys_zone;
levels=#[:#[:#]]; Example: Levels=2:1
Keys_zone=name:size
identifier of the Name:cache;
Size: Metadata cache sizes;
Max_size: Maximum cache space;
Fastcgi_cache Zone|off; The call defines the cache, and the zone is the name in the Keys_zone parameter when the cache is defined by Fastcgi_cache_path;
Fastcgi_cache_key string; Defines how the cache key is used;
Fastcgi_cache_methods get| head| POST ...; The default is get and head for the request that corresponds to which request method is cached;
Fastcgi_cache_valid [code..] time; The response of different response codes is set to cache length;
Note: When invoking a cache, the specified three parameters should be called:
Fastcgi_cache
Fastcgi_cache_key
Fastcgi_cache_valid
Fastcgi_cache_path /var/cache/fastcgi levels=1:1 keys_zone=fastcgicache:10m inactive=5m max_size=1g; # Defines the fastcgi cache server { listen *:80; server_name www.node8.com; root /usr/share /nginx/html; # load configuration files for the default server block. include / etc/nginx/default.d/*.conf; location / { #定义主页文件 index index.html index.php index.htm; } location ~* ^/(images|javascript| js|css|flash|media|static)/ { #定义静态文件自己处理 with an expiry time of 30d expires 30d; } location ~* \.php$ { #将动态资源发往本机的fastcgi处理 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document _root$fastcgi_script_name; include Fastcgi_params; fastcgi_cache fastcgicache; #调用fastcgi的缓存; fastcgi_cache_key $ request_uri; fastcgi_cache_valid 200 302 10m; fastcgi_cache_valid 403 1m; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
* * Enable the Status page for PHP-FPM * *
[[email protected] nginx]# grep "^pm.status_path"/etc/php-fpm.d/#在php-fpm file to enable the item Pm.status_path =/phpfpmstatus #状态页 The polygon URL can be defined by itself; location/phpfpmstatus {#在nginx配置文件中增加此状态页面location fastcgi_pass 127.0.0.1:9000; Fastcgi_param script_filename $fastcgi _script_name; Include Fastcgi_params; }
Restart Nginx and PHP-FPM:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7C/F1/wKioL1bdGOuz0sG_AAA92pQ7lmU698.png "title=" 1.PNG " alt= "Wkiol1bdgouz0sg_aaa92pq7lmu698.png"/>
POOL-FPM: Pool name, mostly www;
Process Manager: How processes are managed;
Start time: start date;
Start since: length of operation;
Accepted Conn: the number of requests received by the current pool;
Listen queue: Request Wait queue, if not 0, the number of processes required to increase fpm;
Max Listen queue: The maximum number of request waiting queues;
Listen queue Len:socket wait-length;
Idle processes: number of idle processes;
Active processes: number of active processes;
Total processes: number of overall processes;
Max Active Processes: The maximum number of active processes, calculated from the start;
Max Childrwn reached:
Slow requests: Slow log feature with FPM enabled, number of slow requests
* * UNIX-based socket file connection php-fpm**
Through the way of listening port processing PHP request, forwarding mode is the TCP protocol, each time to do three handshake and four disconnects, when Nginx and PHP-FPM on the same host, we can based on the local UNIX socket file for communication, improve transmission performance;
Listen =/var/run/php-fpm.sock; #修改php-FPM configuration file to enable it to listen to the UNIX socket file; Fastcgi_pass Unix:/var/run/php-fpm.sock; #修改nginx配置文件中的fastcgi_pass选项;
Nginx (iv) FASTCGI related configuration