标签:php-fpm的pool php-fpm慢执行日志 open_basedir php-fpm进程管理
一、php-fpm的poolvim /usr/local/php-fpm/etc/php-fpm.conf //在[global]部分增加
include = etc/php-fpm.d/*.conf //类似nginx的vhost
mkdir /usr/local/php-fpm/etc/php-fpm.d/
cd /usr/local/php-fpm/etc/php-fpm.d/
vim www.conf //内容如下
[www]
listen = /tmp/php-fcgi.sock
listen.mode=666
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
vim chinantfy.conf //内容如下
[chinantfy]
listen = /tmp/chinantfy.sock
listen.mode=666
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
/usr/local/php-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm restart/reload //重启或者重新加载配置文件
ps aux | grep php-fpm
ls /usr/local/nginx/conf/vhost/
vim /usr/local/nginx/conf/vhost/test.com.conf
vim /usr/local/php-fpm/etc/php-fpm.d/www.conf //加入如下内容
request_slowlog_timeout = 1 //超过1秒就会记录,一般用2 即可
slowlog = /usr/local/php-fpm/var/log/www-slow.log
/usr/local/php-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm restart/reload
/usr/local/nginx/sbin/nginx -t
/etc/init.d/nginx reload
vim /data/wwwroot/test.com/sleep.php //写入如下内容
<?php
echo "test slow log";
sleep(2);
echo "done";
?>
curl -x127.0.0.1:80 test.com/sleep.php
cat /usr/local/php-fpm/var/log/www-slow.log
log文件显示php第三行导致运行变慢
vim /usr/local/php-fpm/etc/php-fpm.d/www.conf //加入如下内容
php_admin_value[open_basedir]=/data/wwwroot/123test.com:/tmp/ //注意这里路径特意改错了
/usr/local/php-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm reload
curl -x127.0.0.1:80 test.com/sleep.php -I
vi /usr/local/php-fpm/etc/php.ini //修改下面两行
error_log=/usr/local/php-fpm/var/log/php_errors.1og
error_reporting =E_ALL
/usr/local/php-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm reload
touch /usr/local/php-fpm/var/log/php_errors.1og
chmod 777 /usr/local/php-fpm/var/log/php_errors.1og
curl -x127.0.0.1:80 test.com/sleep.php -I
再次更改www.conf,修改路径,再次测试
php_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp/
/usr/local/php-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm reload
再次测试
查看错误日志
cat /usr/local/php-fpm/etc/php-fpm.d/www.conf
pm = dynamic //动态进程管理,也可以是static,静态时下面几行设置不生效
pm.max_children = 50 //最大子进程数,ps aux可以查看
pm.start_servers = 20 //启动服务时会启动的进程数
pm.min_spare_servers = 5 //定义在空闲时段,子进程数的最少数量,如果达到这个数值时,php-fpm服务会自动派生新的子进程。
pm.max_spare_servers = 35 //定义在空闲时段,子进程数的最大值,如果高于这个数值就开始清理空闲的子进程。
pm.max_requests = 500 //定义一个子进程最多处理的请求数,也就是说在一个php-fpm的子进程最多可以处理这么多请求,当达到这个数值时,它会自动退出。
51.php-fpm的pool、php-fpm慢执行日志open_basedir、php-fpm进程
标签:php-fpm的pool php-fpm慢执行日志 open_basedir php-fpm进程管理
原文地址:http://blog.51cto.com/13569831/2110355