标签:php-fpm的pool
12.21 php-fpm的pool
1. 添加pool:
[root@hao-01 ~]# vim /usr/local/php-fpm/etc/php-fpm.conf
添加第二个pool:
[hao1.com]
listen = /tmp/hao1.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
2. 查看配置有没有语法错误?
[root@hao-01 ~]# /usr/local/php-fpm/sbin/php-fpm -t
3. 重新加载配置:
[root@hao-01 ~]# /etc/init.d/php-fpm reload
4. 查找php-fpm进程(pool hao1.com 可查到了):
[root@hao-01 ~]# ps aux |grep php-fpm
5. aaa.com网站设定为第二个pool(hao1.com)
[root@hao-01 ~]# vim /usr/local/nginx/conf/vhost/aaa.com.conf
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass unix:/tmp/hao1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/wwwroot/default$fastcgi_script_name;
}
多个pool情况下,每一个pool对应一个相关配置文件:
1. 查看[www]和[hao1.com]相关下面的配置 并拷贝到剪切板备用:
[root@hao-01 ~]# cat /usr/local/php-fpm/etc/php-fpm.conf
2. 编辑 php-fpm.conf主配置文件:
[root@hao-01 ~]# vim /usr/local/php-fpm/etc/php-fpm.conf
添加如下一行(添加这行就可以www和hao1.com配置设定成各自独立的文件):
include = etc/php-fpm.d/*.conf
删除(删除前一定要先备份):[www]和[hao1.com]相关下面的配置
删除光标行及下面100行:100 dd
3. 创建.../php-fpm.d目录(用于存放后缀.conf文件):
[root@hao-01 ~]# mkdir /usr/local/php-fpm/etc/php-fpm.d
4. 进入.../php-fpm.d目录:
[root@hao-01 ~]# cd /usr/local/php-fpm/etc/php-fpm.d
5. 创建www.conf文件,并添加如下内容:
[root@hao-01 php-fpm.d]# vim www.conf
之前备份的[www]相关配置:
[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
6. 创建hao1.com.conf文件,并添加如下内容:
[root@hao-01 php-fpm.d]# vim hao1.com.conf
之前备份的[hao1.com]相关配置:
[hao1.com]
listen = /tmp/hao1.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
7. 查看配置有没有语法错误?
[root@hao-01 php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t
8. 重新加载配置:
[root@hao-01 php-fpm.d]# /etc/init.d/php-fpm reload
9. 查找php-fpm进程(pool hao1.com 可查到了):
[root@hao-01 php-fpm.d]# ps aux |grep php-fpm
12.22 php-fpm慢执行日志
编辑.../php-ini配置文件,如图:
[root@hao-01 ~]# vim /usr/local/php-fpm/etc/php-ini
1. 编辑.../www.conf文件:
[root@hao-01 ~]# 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
2. 查看配置有没有语法错误?
[root@hao-01 ~]# /usr/local/php-fpm/sbin/php-fpm -t
3. 重新加载配置:
[root@hao-01 ~]# /etc/init.d/php-fpm reload
4. 查看是否生成www-slow.log日志文件:
[root@hao-01 ~]# ls /usr/local/php-fpm/var/log/www-slow.log
添加内容:
<?php
echo "test slow log";
sleep(2);
echo "done";
?>
5. curl访问test.com网站下,sleep.php文件(慢2秒执行)
[root@hao-01 ~]# curl -x127.0.0.1:80 test.com/sleep.php -I
6. 查看慢执行日志内容:
[root@hao-01 ~]# cat /usr/local/php-fpm/var/log/www-slow.log
本文出自 “主内安详” 博客,请务必保留此出处http://zhuneianxiang.blog.51cto.com/11621252/1956716
标签:php-fpm的pool
原文地址:http://zhuneianxiang.blog.51cto.com/11621252/1956716