The experimental environment is as follows:
Node1
|
Apache Server |
10.1.12.12 |
| Node2 |
php-fpm |
10.1.12.13 |
System Environment: CentOS 7
Node1
Apache server confirms that it has the following module
~]# httpd-m |grep fcgiproxy_fcgi_module (shared)
Define a virtual host
~]# vi/etc/httpd/conf.d/vhost.conf
<virtualhost *:80> servername www.blackcao.com DocumentRoot "/web/www" CustomLog logs/black_access.log conbaind ErrorLog logs/black_error.log <Directory "/web/www" > Options none allowoverride none require all granted </directory> proxyrequests off proxypassmatch ^/(ping|status|. *\.php) $ fcgi://10.1.12.13:9000/data/application/$1 Directoryindex index.php</virtualhost>
Proxypassmatch ping|status| the front end PHP end of the request is forwarded to the backend of the PHP server back-end page storage location customization;
Create a configuration file for the PHP status page
]# vi/etc/httpd/conf.d/status.conf<directory/status> SetHandler status-server Require all Granted< ;/directory>
Set up a Virtual Host home page directory
]# mkdir-pv/web/www
[[email protected] ~]# httpd-t[[email protected] ~]# systemctl start httpd.service[[email protected] ~]# SS-TNL
Check the syntax, start the service, check if the port is listening properly,
Node2
~]# Vi/etc/php-fpm.d/listen = 10.1.12.13:9000 must be listening on a port that can communicate with the external address of the outer network listen.allowed_clients = 10.1.12.12 IP for HTTP serve R host Pm.status_path =/status php Status Page ping.path =/ping can check if PHP service is normal ping.response = Pong above ping response, pong Description Normal, not responding Indicate a problem
Create a Web file directory (corresponding to the path defined in the virtual machine above)
~]# mkdir-p/data/application~]# vi/data/application/index.php<?php phpinfo ();? >
Configuration complete, start the service to see if Port 9000 is in listening state
Configuration options for PHP-FPM
Listen.backlog =-1
If the connection pool definition can have up to 50 connections, when there are 55. This option defines the length of the backup queue, 1 means no limit and may be modified if memory is not enough
PM = dynamic
Define processor management mechanism: static (using a fixed number of sub-processes)
Dynamic (using variable number of sub-processes)
Pm.max_children : The maximum number of child processes, the maximum capacity of the connection pool;
pm.start_servers : The number of child processes started when the service started;
pm.min_spare_servers Minimum number of idle child processes
pm.max_spare_servers Maximum number of idle child processes
rlimit_files = 1024x768 The number of files that can be opened, each connection requires a socket file, up to 50
Rlimit_core = 0 The amount of memory space the core can use, 0 means no Limit
Pm.status_path =/status
Ping.path =/ping Monitor fpm for normal operation
Ping.response = Pong
Php_value[session.save_path] =/var/lib/php/session where the session is stored
Status Output information
Pool:www #连接池名称
Process Manager:dynamic #进程管理器类型
Start time:11/oct/2016:11:22:04 +0800 #启动日期时间
Start since:917 # run time
Accepted Conn:9 # Number of requests that have been processed by the connection pool
Listen queue:0 # request Queue Length
Max Listen queue:0 # request queue Maximum length
Listen Queue len:128 # The length of the socket waiting queue
Idle processes:4 # Number of free processes
Active Processes:1 # Number of active processes
Total Processes:5 # Overall number of processes in the connection pool
Max Active Processes:2 # The maximum number of active processes in the connection pool
Max Children reached:0 # Number of maximum number of process limit in connection pool reached
Slow requests:0: The number of slow requests is logged when Slow-log is enabled
This article is from the "Legendary Pig" blog, make sure to keep this source http://cszdz.blog.51cto.com/11892760/1879342
apache+php-fpm