摘要:php-fpm的pool cd /usr/local/php-fpm/etc/ vim /usr/local/php-fpm/etc/php-fpm.conf //在[global]部分增加 include = etc/php-fpm.d/*.conf mkdir /usr/local/php-fpm/etc/php-fpm.d/ cd /usr/local/p
php-fpm的pool
cd /usr/local/php-fpm/etc/
vim /usr/local/php-fpm/etc/php-fpm.conf //在[global]部分增加
include = etc/php-fpm.d/*.conf
mkdir /usr/local/php-fpm/etc/php-fpm.d/
cd /usr/local/php-fpm/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 aming.conf //内容如下
[aming.com] 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-fpm/sbin/php-fpm -t
/etc/init.d/php-fpm restart
ps aux |grep php-fpm
cd/usr/local/nginx/conf/vhost
vim aaa.com.conf
location ~ .php$ { include fastcgi_params; fastcgi_pass unix:/tmp/aming.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/wwwroot/default$fastcgi_script_name; }
php-fpm慢执行日志
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
检测 /usr/local/php-fpm/sbin/php-fpm -t
加载 /etc/init.d/php-fpm reload
再查看一下日志有没有生成
ls/usr/local/php-fpm/var/log/
cat /usr/local/nginx/conf/vhost/test.com.conf
vi/usr/local/nginx/conf/vhost/test.com.conf
配置nginx的虚拟主机test.com.conf,把unix:/tmp/php-fcgi.sock改为unix:/tmp/www.sock;
重新加载nginx服务
/usr/local/nginx/sbin/nginx -t //检测是否有错误
/usr/local/nginx/sbin/nginx -s reload //重新加载
vim /data/wwwroot/test.com/sleep.php //写入如下内容
<?php
echo"test slow log";
sleep(2);
echo"done";
?>
如果想把错误直接显示在屏幕上,暂且不看日志。修改php.ini,设置如下:
vi /usr/local/php-fpm/etc/php.ini
display_errors = On
[root@localhost php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php test slow logdo [root@localhost php-fpm.d]# cat /usr/local/php-fpm/var/log/www-slow.log [04-Jan-2018 23:12:04] [pool www] pid 5353 script_filename = /data/wwwroot/test.com/sleep.php [0x00007ffb01545298] sleep() /data/wwwroot/test.com/sleep.php:3
php-fpm定义open_basedir
open_basedir 的作用是限制php在指定的目录里活动。
vim /usr/local/php-fpm/etc/php-fpm.d/www.conf//加入如下内容
php_admin_value[open_basedir]=/data/wwwroot/test.com:/tmp/
进行测试 curl -x127.0.0.1:80 test.com/3.php -I
配置错误日志
vi /usr/local/php-fpm/etc/php.ini
display_errors = Off
error_log=/usr/local/php-fpm/var/log/php_errors.log
error_reporting = E_ALL
grep error_log/usr/local/php-fpm/etc/php.ini
ls/usr/local/php-fpm/var/log/
touch/usr/local/php-fpm/var/log/php_errors.log
chmod 777/usr/local/php-fpm/var/log/php_errors.log //防止不能正常写入
/etc/init.d/php-fpm restart //重启
再次测试 curl -x127.0.0.1:80 test.com/3.php -I
查看错误日志 cat/usr/local/php-fpm/var/log/php_errors.log
php-fpm进程管理
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的子进程最多可以处理这么多请求,当达到这个数值时,它会自动退出。
相关文章推荐
虚拟主机的专业参数,分别都是什么意思?2022-09-09
中非域名注册规则是怎样的?注册域名有什么用处? 2022-01-10
HostEase新年活动促销 美国/香港主机全场低至五折2021-12-28
HostGator下载完整备份教程分享2021-12-28
Flink中有界数据与无界数据的示例分析2021-12-28