12.21 php-fpm的pool,
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了12.21 php-fpm的pool,相关的知识,希望对你有一定的参考价值。
12.21 php-fpm的pool
1. 添加pool:
[[email protected] ~]# 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. 查看配置有没有语法错误?
[[email protected] ~]# /usr/local/php-fpm/sbin/php-fpm -t
3. 重新加载配置:
[[email protected] ~]# /etc/init.d/php-fpm reload
4. 查找php-fpm进程(pool hao1.com 可查到了):
[[email protected] ~]# ps aux |grep php-fpm
5. aaa.com网站设定为第二个pool(hao1.com)
[[email protected] ~]# 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]相关下面的配置 并拷贝到剪切板备用:
[[email protected] ~]# cat /usr/local/php-fpm/etc/php-fpm.conf
2. 编辑 php-fpm.conf主配置文件:
[[email protected] ~]# 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文件):
[[email protected] ~]# mkdir /usr/local/php-fpm/etc/php-fpm.d
4. 进入.../php-fpm.d目录:
[[email protected] ~]# cd /usr/local/php-fpm/etc/php-fpm.d
5. 创建www.conf文件,并添加如下内容:
[[email protected] 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文件,并添加如下内容:
[[email protected] 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. 查看配置有没有语法错误?
[[email protected] php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t
8. 重新加载配置:
[[email protected] php-fpm.d]# /etc/init.d/php-fpm reload
9. 查找php-fpm进程(pool hao1.com 可查到了):
[[email protected] php-fpm.d]# ps aux |grep php-fpm
12.22 php-fpm慢执行日志
编辑.../php-ini配置文件,如图:
[[email protected] ~]# vim /usr/local/php-fpm/etc/php-ini
1. 编辑.../www.conf文件:
[[email protected] ~]# 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. 查看配置有没有语法错误?
[[email protected] ~]# /usr/local/php-fpm/sbin/php-fpm -t
3. 重新加载配置:
[[email protected] ~]# /etc/init.d/php-fpm reload
4. 查看是否生成www-slow.log日志文件:
[[email protected] ~]# 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秒执行)
[[email protected] ~]# curl -x127.0.0.1:80 test.com/sleep.php -I
6. 查看慢执行日志内容:
[[email protected] ~]# cat /usr/local/php-fpm/var/log/www-slow.log
本文出自 “主内安详” 博客,请务必保留此出处http://zhuneianxiang.blog.51cto.com/11621252/1956716
以上是关于12.21 php-fpm的pool,的主要内容,如果未能解决你的问题,请参考以下文章
12.21 php-fpm的pool;12.22 php-fpm慢执行日志;12.23;12.24
12.21 php-fpm的pool;12.22 php-fpm慢执行日志;12.23 ;12.24
12.21 php-fpm的pool 12.22 php-fpm慢执行日志 12.23 open_b
12.21 php-fpm的pool 12.22 php-fpm慢执行日志 12.23 open_b
12.21 php-fpm的pool 12.22 php-fpm慢执行日志 12.23 open_basedir 12.24 php-fpm进程管理