The pool of PHP-FPM
Editing a configuration file
vim /usr/local/php-fpm/etc/php-fpm.conf
在配置文件中添加如下的内容[test.com]listen = /tmp/test.socklisten.mode = 666user = php-fpmgroup = php-fpmpm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024
Check the configuration file for errors and reload
/usr/local/php-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm reload
Configure Nginx to use different spool, I use the site for test.com
vim /usr/local/nginx/conf/vhost/test.com.conf
Locate Fastcgi_pass Unix: This line, change to:
fastcgi_pass unix:/tmp/test.sock;
The same PHP-FPM configuration file can be cut off.
vim /usr/local/php-fpm/etc/php-fpm.conf
Add the following line in the configuration file
include = etc/php-fpm.d/*.conf
Then the configuration file can be placed under PHP-FPM.D
Execute command
mkdir php-fpm.d
Then you can separate the configuration files separately
PHP-FPM Slow Execution Log
Project with PHP development, in the production process, it should be a period of time to monitor the PHP script running state, which PHP process is too slow, what error logs.
How do you see a PHP script that is slow to detect? Then you can view the php-fpm slow log.
Edit a configuration file, mine is www.conf
vim /usr/local/php-fpm/etc/php-fpm.d/www.conf
Add the following content to the file
request_slowlog_timeout = 1
slowlog = /usr/local/php-fpm/var/log/www-slow.log
request_slowlog_timeout = 1
Set the time, more than 1 seconds
slowlog = /usr/local/php-fpm/var/log/www-slow.log
#定义日志存放的地址
Check the configuration file and reload the configuration file after changing the profile
/usr/local/php-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm reload
Test configuration is successful, my www.conf profile is aaa.com This site is using the
"" In the site aaa.com create a name sleep.php test file ' vim/data/wwwroot/aaa.com/sleep.php ' in the file add the following content <?phpecho "test slow Log"; Sleep (2); echo "Done";? > Access to sleep.php under aaa.com curl-x192.168.71.131:80 aaa.com/sleep.php Access After completion view slow log ' cat/usr/local/php-fpm/var/log/ Www-slow.log '-----# Open_basediropen_basedir's role is to restrict PHP activity in the specified directory to edit a configuration file, mine is www.conf ' vim/usr/local/php-fpm/etc/ Php-fpm.d/www.conf ' Add the following line in the config file to finish defining the ' php_admin_value[open_basedir]=/data/wwwroot/aaa.com:/tmp/' # PHP-FPM process management! [] (http://i2.51cto.com/images/blog/201806/13/a2dcd5cf1f2499103b93592a3012e8a3.png?x-oss-process=image/ watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) ' PM = Dynamic '//\ \ \ \ \ \ \ \ \ \ pm.max_children = 50 '//maximum number of child processes, PS aux can view ' pm.start_servers = 20 '//number of processes that start the service ' PM.M In_spare_servers = 5 '//defines the minimum number of child processes in the idle period, and if this value is reached, the PHP-FPM service automatically derives the new child process. ' Pm.max_spare_servers = 35 '//defines the maximum number of child processes in the idle period, and if above this value begins to clean up idle child processes. ' pm.max_requests = 500 '//defines the maximum number of requests processed by a child process, that is, in a PHP-FPM child process up toSo many requests can be processed, and when this value is reached, it automatically exits
PHP-FPM pool, slow execution log, Open_basedir, process management