【CentOS 7LNMP架构38】,php -fpm慢执行日志#180110

摘要:hellopasswd php -fpm慢执行日志 vi /usr/local/php-fpm/etc/php-fpm.d/www.conf request_slowlog_timeout=1 slowlog=/usr/local/php-fpm/var/log/www-slow.log 配置nginx的虚拟主机test.com.conf,把unix:/tmp/php-fcgi.soc

hellopasswd


php -fpm慢执行日志

vi /usr/local/php-fpm/etc/php-fpm.d/www.conf request_slowlog_timeout=1 slowlog=/usr/local/php-fpm/var/log/www-slow.log

timg.jpg

配置nginx的虚拟主机test.com.conf,把unix:/tmp/php-fcgi.sock改为unx:/tmp/www.sock

重新加载nginx服务

vi /data/wwwroot/test.com/sleep.php

<?php echo "test slow log"; sleep(2); echo "done"; ?>

curl -x 127.0.0.1:80 test.com/sleep.php

cat /usr/local/php-fpm/var/log/www-slow.log

[root@localhost php-fpm.d]# vi www.conf 1 [www] 2 listen = /tmp/php-fcgi.sock 3 listen.mode = 666 4 user = php-fpm 5 group = php-fpm 6 pm = dynamic 7 pm.max_children = 50 8 pm.start_servers = 20 9 pm.min_spare_servers = 5 10 pm.max_spare_servers = 35 11 pm.max_requests = 500 12 rlimit_files = 1024 13 request_slowlog_timeout = 1 14 slowlog = /usr/local/php-fpm/var/log/www-slow.log [root@localhost php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t [10-Jan-2018 08:13:55] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful [root@localhost php-fpm.d]# /etc/init.d/php-fpm reload Reload service php-fpm done

[root@localhost php-fpm.d]# ls /usr/local/php-fpm/var/log/ php-fpm.log www-slow.log [root@localhost php-fpm.d]# vi /data/wwwroot/test.com/sleep.php 1 <?php 2 echo "test slow log"; 3 sleep(2); 4 echo "done"; 5 ?>

[root@localhost php-fpm.d]# curl -x 127.0.0.1:80 test.com/sleep.php

[root@localhost php-fpm.d]# vi /usr/local/php-fpm/etc/php.ini /display_errors 462 ; Default Value: On 463 ; Development Value: On 464 ; Production Value: Off 465 ; http://php.net/display-errors 466 display_errors = Off 467 468 ; The display of errors which occur during PHP\'s startup sequence are handled 469 ; separately from display_errors. PHP\'s default behavior is to suppress those 470 ; errors from clients. Turning the display of startup errors on can be useful in 471 ; debugging configuration problems. We strongly recommend you 472 ; set this to \'off\' for production servers. 473 ; Default Value: Off

将display_errors = Off改为On

[root@localhost php-fpm.d]# vi /usr/local/php-fpm/etc/php.ini /display_errors 462 ; Default Value: On 463 ; Development Value: On 464 ; Production Value: Off 465 ; http://php.net/display-errors 466 display_errors = On 467 468 ; The display of errors which occur during PHP\'s startup sequence are handled 469 ; separately from display_errors. PHP\'s default behavior is to suppress those 470 ; errors from clients. Turning the display of startup errors on can be useful in 471 ; debugging configuration problems. We strongly recommend you 472 ; set this to \'off\' for production servers. 473 ; Default Value: Off [root@localhost php-fpm.d]# /etc/init.d/php-fpm reload Reload service php-fpm done

[root@localhost php-fpm.d]# curl -x 127.0.0.1:80 test.com/sleep.php [root@localhost php-fpm.d]# cat /usr/local/php-fpm/var/log/www-slow.log