标签:php slow log sts work clu tmp 最大值 requests www.
一、 php-fpm的poolvim /usr/local/php/etc/php-fpm.conf//在[global]部分增加
include = etc/php-fpm.d/*.conf
mkdir /usr/local/php/etc/php-fpm.d/
cd /usr/local/php/etc/php-fpm.d
vim www.conf //内容如下
[www]
listen = /tmp/www.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 www.conf //内容如下
[www]
listen = /tmp/www.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 aming.conf //内容如下
[aming]
listen = /tmp/aming.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/sbin/php-fpm –t
/etc/init.d/php-fpm restart
vim /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的虚拟主机riven.work.conf,把unix:/tmp/php-fcgi.sock改为unix:/tmp/www.sock
重新加载nginx服务:/usr/local/nginx/sbin/nginx -s 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
vim /usr/local/php-fpm/etc/php-fpm.d/aming.conf//加入如下内容
php_admin_value[open_basedir]=/data/wwwroot/riven.work:/tmp/
创建测试php脚本,进行测试
再次更改riven.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的子进程最多可以处理这么多请求,当达到这个数值时,它会自动退出。
php-fpm的pool 、慢执行日志、 open_basedir及 php-fpm进程管理
标签:php slow log sts work clu tmp 最大值 requests www.
原文地址:http://blog.51cto.com/10690709/2129162