[[email protected] php]# ls etc/
pear.conf php-fpm.conf php.ini
Where php.ini is the global configuration of PHP; php-fpm.conf is the management php-fpm service configuration.
To configure the PHP-FPM service, you need to empty its original content and write new content:
[Email protected] php]# > etc/php-fpm.conf
[Email protected] php]# vim etc/php-fpm.conf
[Global]
PID =/usr/local/php/var/run/php-fpm.pid
Error_log =/usr/local/php/var/log/php-fpm.log
[www] #pool的名字
listen =/tmp/www.sock# listener sock or ip:port, can be customized WWW.S Ock
user = php-fpm# Master php-fpm
Group = Genus Php-fpm# PHP-FPM
Listen.owner = nobody# Listener user, Nginx-->nobody
Listen.group = nobody# Listener Group, Nginx-->nobody
PM = dynamic# The way the child process is generated, dynamic is more efficient, and if you change to static, it is always the Max_children child process
Pm.max_children = 50# Maximum number of child processes
Pm.start_servers = 20# starts 20 sub-processes
pm.min_spare_servers = * At least 5 sub-processes are started when idle
Pm.max_spare_servers = 35# up to 35 child processes when idle
Pm.max_requests = 500# The entire lifecycle of each subprocess processes 500 requests for automatic destruction
Rlimit_files = 1024# The limit of file descriptors used by each child process, slightly larger can be
[WWW1]
Listen =/tmp/www1.sock
user = PHP-FPM
Group = PHP-FPM
PM = dynamic
Pm.max_children = 50
Pm.start_servers = 20
Pm.min_spare_servers = 5
Pm.max_spare_servers = 35
Pm.max_requests = 500
Rlimit_files = 1024
Restart the PHP-FPM service after the check is correct:
[Email protected] php]#/usr/local/php/sbin/php-fpm-t
[13-jan-2017 23:14:06] Notice:configuration file/usr/local/php/etc/php-fpm.conf Test is successful
[Email protected] php]#/etc/init.d/php-fpm restart
Gracefully shutting down php-fpm. Done
Starting php-fpm Done
PHP-FPM can have a number of different pool (such as the above www and WWW1 is two pool), different sites with different domain names using different pool, different pool needs to listen to different sock, or different ip:port. Different domains can be mapped to different pool
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8D/F6/wKioL1ixChvCH3qeAADwY8dXYu8504.png-wh_500x0-wm_ 3-wmp_4-s_4004824544.png "title=" 1.png "alt=" Wkiol1ixchvch3qeaadwy8dxyu8504.png-wh_50 "/>
For example, we can write multiple virtual hosts in this directory, so that different virtual hosts use different pool, such as www.test.com using www,www.aaa.com www1 and so on, using different pool, you can set different permissions. and avoid the risk of using a pool to cause multiple sites to be down at the same time.
[[email protected] vhosts]# ls
Default.conf test.conf
Simply specify which pool you are using in each virtual host
You can add slow.log to each pool to see where the site is causing slowness to track website performance, or to set accessible directories for each site
[Email protected] php]# vim etc/php-fpm.conf
[Global]
PID =/usr/local/php/var/run/php-fpm.pid
Error_log =/usr/local/php/var/log/php-fpm.log
[WWW]
Listen =/tmp/www.sock
user = PHP-FPM
Group = PHP-FPM
Listen.owner = Nobody
Listen.group = Nobody
PM = dynamic
Pm.max_children = 50
Pm.start_servers = 20
Pm.min_spare_servers = 5
Pm.max_spare_servers = 35
Pm.max_requests = 500
Rlimit_files = 1024
Slowlog =/tmp/www_slog.log
Request_slowlog_timeout = 1
php_admin_value[open_basedir]=/data/www/:/tmp/
[WWW1]
Listen =/tmp/www1.sock
user = PHP-FPM
Group = PHP-FPM
PM = dynamic
Pm.max_children = 50
Pm.start_servers = 20
Pm.min_spare_servers = 5
Pm.max_spare_servers = 35
Pm.max_requests = 500
Rlimit_files = 1024
[Email protected] vhosts]#/usr/local/php/sbin/php-fpm-t
[23-feb-2017 00:21:02] Notice:configuration file/usr/local/php/etc/php-fpm.conf Test is successful
[Email protected] vhosts]#/etc/init.d/php-fpm restart
Gracefully shutting down php-fpm. Done
LNMP Build 5:PHP-FPM configuration file