php-fpm的pool
Nginx可以配置多个主机,php-fpm也可以配置多个pool
配置多个pool可以隔离开各个网站,例如一个网站有问题,把PHP资源耗尽了,那其他网站和这个网站使用的是同一个pool 那也会受到影响,所以我们可以给每个站点都配置一个pool。网站报错502一般和PHP有关。
给不同的站点分别配置不同的pool
给两个站点分别配置不同的pool
[root@lnmp ~]# ps -ef |grep php
root 24261 1 0 04:00 ? 00:00:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)
php-fpm 24262 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24263 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24264 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24265 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24266 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24267 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24268 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24269 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24270 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24271 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24272 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24273 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24274 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24275 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24276 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24277 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24278 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24279 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24280 24261 0 04:00 ? 00:00:00 php-fpm: pool www
php-fpm 24281 24261 0 04:00 ? 00:00:00 php-fpm: pool www
root 30209 30190 0 08:19 pts/3 00:00:00 grep --color=auto php
[root@lnmp ~]#
/进入配置文件目录
[root@lnmp ~]# cd /usr/local/php-fpm/etc/
/添加一个pool为123.com
[root@lnmp etc]# vim php-fpm.conf
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[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
[123.com]
listen = /tmp/123.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
/检查语法
[root@lnmp etc]# /usr/local/php-fpm/sbin/php-fpm -t
[07-Sep-2021 08:21:12] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful
/重启
[root@lnmp etc]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@lnmp etc]#
/看到多了新的pool
[root@lnmp etc]# ps -aux |grep php
root 30219 0.0 0.2 231952 5088 ? Ss 08:21 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)
php-fpm 30220 0.0 0.2 231892 4808 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30221 0.0 0.2 231892 4808 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30222 0.0 0.2 231892 4808 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30223 0.0 0.2 231892 4808 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30224 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30225 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30226 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30227 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30228 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30229 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30230 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30231 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30232 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30233 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30234 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30235 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30236 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30237 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30238 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30239 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool www
php-fpm 30240 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30241 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30242 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30243 0.0 0.2 231892 4812 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30244 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30245 0.0 0.2 231892 4816 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30246 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30247 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30248 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30249 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30250 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30251 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30252 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30253 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30254 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30255 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30256 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30257 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30258 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
php-fpm 30259 0.0 0.2 231892 4820 ? S 08:21 0:00 php-fpm: pool 123.com
root 30261 0.0 0.0 112824 984 pts/3 R+ 08:23 0:00 grep --color=auto php
[root@lnmp etc]#
[root@lnmp etc]# cd /usr/local/nginx/conf/vhost/
[root@lnmp vhost]# vim default.conf
server
{
listen 80 default_server;
server_name aaa.com;
index index.html index.htm index.php;
root /data/nginx/default;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/123.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/nginx/test.com$fastcgi_script_name;
}
}
# fastcgi_pass unix:/tmp/123.sock; 主要就是修改这一行配置文件选择不同的pool。
[root@lnmp vhost]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@lnmp vhost]# /usr/local/nginx/sbin/nginx -s reload
配置拆分多个pool
在nginx.conf这个配置文件下有一行配置文件为 include vhost/*.conf; 他的作用为识别指定目录下以conf为结尾的配置文件,让每个站点为一个配置文件。
/进入配置文件目录
[root@lnmp vhost]# cd /usr/local/php-fpm/etc/
# 加入一行include
[root@lnmp etc]# vim php-fpm.conf
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
include = etc/php-fpm.d/*.conf
/创建存放配置文件的目录
[root@lnmp etc]# mkdir php-fpm.d
[root@lnmp etc]# cd php-fpm.d/
[root@lnmp php-fpm.d]# vim 123.conf
[123.com]
listen = /tmp/123.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
request_slowlog_timeout = 1
slowlog = /usr/local/php-fpm/var/log/www-slow.log
[root@lnmp 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
[root@lnmp php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t
[19-Aug-2021 07:40:02] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf
test is successful
/重启服务
[root@lnmp php-fpm.d]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
/查看一下sock文件
[root@lnmp php-fpm.d]# ls /tmp/*.sock
/tmp/123.sock /tmp/mysql.sock /tmp/php-fcgi.sock
[root@lnmp php-fpm.d]# ps -ef |grep php
root 30282 1 0 08:30 ? 00:00:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)
php-fpm 30283 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30284 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30285 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30286 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30287 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30288 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30289 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30290 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30291 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30292 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30293 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30294 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30295 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30296 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30297 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30298 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30299 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30300 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30301 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30302 30282 0 08:30 ? 00:00:00 php-fpm: pool 123.com
php-fpm 30303 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30304 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30305 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30306 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30307 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30308 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30309 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30310 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30311 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30312 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30313 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30314 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30315 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30316 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30317 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30318 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30319 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30320 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30321 30282 0 08:30 ? 00:00:00 php-fpm: pool www
php-fpm 30322 30282 0 08:30 ? 00:00:00 php-fpm: pool www
root 30325 30190 0 08:30 pts/3 00:00:00 grep --color=auto php
[root@lnmp php-fpm.d]#
php-fpm查看慢执行日志
通过配置慢执行日志,可以让我们清晰的了解到PHP脚本在哪里执行时间长,可以定位到哪一行。
/添加两行配置文件
[root@lnmp php-fpm.d]# 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
[root@lnmp php-fpm.d]# /usr/local/php-fpm/sbin/php-fpm -t
[07-Sep-2021 08:32:31] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf
test is successful
[root@lnmp php-fpm.d]# vim /usr/local/nginx/conf/vhost/test.com.conf
server
{
listen 80;
server_name test.com;
index index.html index.htm index.php;
root /data/nginx/test.com;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/nginx/test.com$fastcgi_script_name;
}
}
/重载PHP服务
[root@lnmp php-fpm.d]# /etc/init.d/php-fpm reload
Reload service php-fpm done
/可以看到我们配置的路径已经多了一个
[root@lnmp php-fpm.d]# ls /usr/local/php-fpm/var/log/
php-fpm.log www-slow.log
/现在的www-slow.log还是一个空文件。只会记录执行时间大于1s的日志
[root@lnmp php-fpm.d]# cat /usr/local/php-fpm/var/log/www-slow.log
测试 写一个慢执行文件
[root@lnmp php-fpm.d]# vim /data/nginx/test.com/sleep.php
<?php
echo "test slow log";
sleep(2);
echo "done";
?>
执行这个脚本的时候可以明显看到慢了一下。
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php
test slow logdone[root@lnmp php-fpm.d]#
可以看到日志多出一行。说哪个文件,第三行 sellp()问题。
[root@lnmp php-fpm.d]# cat /usr/local/php-fpm/var/log/www-slow.log
[07-Sep-2021 10:55:16] [pool 123.com] pid 30879
script_filename = /data/nginx/test.com/sleep.php
[0x00007fdbdc54d270] sleep() /data/nginx/test.com/sleep.php:3
php-fpm定义open_basedir
open_basedir目的就是安全,httpd可以针对每个虚拟机设置一个open_basedir
php-fpm同样也可以对不同的pool设置的不同的open_basedir
修改配置文件,特意配置为错误路径
添加一行配置文件,其中test.com的路径为错误路径
[root@lnmp php-fpm.d]# vim /usr/local/php-fpm/etc/php-fpm.d/www.conf
php_admin_value[open_basedir]=/data/nginx/wwwtest.com:/tmp/
[root@lnmp php-fpm.d]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
/测试发现这些PHP文件都无法访问,就是因为php open_basedir做了限制。
[root@lnmp php-fpm.d]# ls /data/nginx/test.com/
1.js 1.jss 2.jpg 2.js 3.php admin index.html sleep.php
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php -I
HTTP/1.1 404 Not Found
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 02:51:12 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/3.php -I
HTTP/1.1 404 Not Found
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 02:51:45 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
把配置文件改为正确的
发现可以正常使用
[root@lnmp php-fpm.d]# vim /usr/local/php-fpm/etc/php-fpm.d/www.conf
php_admin_value[open_basedir]=/data/nginx/test.com:/tmp/
[root@lnmp php-fpm.d]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/3.php -I
HTTP/1.1 200 OK
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 02:57:52 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php -I
HTTP/1.1 200 OK
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 02:58:00 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
配置错误日志
配置记录php执行错误的日志
配置
[root@lnmp php-fpm.d]# vim /usr/local/php-fpm/etc/php.ini
display_errors = Off
log_errors = On
error_log = /usr/local/php-fpm/var/log/php_error.log
;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL
再次将php的配置文件改错
[root@lnmp php-fpm.d]# vim /usr/local/php-fpm/etc/php-fpm.d/www.conf
php_admin_value[open_basedir]=/data/nginx/wwwtest.com:/tmp/
这个日志文件不会自动生成,所以我们自己创建一个,并授权。
[root@lnmp php-fpm.d]# touch /usr/local/php-fpm/var/log/php_error.log
[root@lnmp php-fpm.d]# chmod 777 /usr/local/php-fpm/var/log/php_error.log
[root@lnmp php-fpm.d]# /etc/init.d/php-fpm restart
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/3.php -I
HTTP/1.1 404 Not Found
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 03:21:22 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php -I
HTTP/1.1 404 Not Found
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 03:21:32 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php
No input file specified.
查看错误日志,显示open_basedir限制生效,目录不能访问
[root@lnmp php-fpm.d]# cat /usr/local/php-fpm/var/log/php_error.log
[07-Sep-2021 04:10:25 UTC] PHP Warning: Unknown: open_basedir restriction in effect. File(/data/nginx/test.com/3.php) is not within the allowed path(s): (/data/nginx/wwwtest.com:/tmp/) in Unknown on line 0
[07-Sep-2021 04:10:25 UTC] PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[07-Sep-2021 04:10:45 UTC] PHP Warning: Unknown: open_basedir restriction in effect. File(/data/nginx/test.com/sleep.php) is not within the allowed path(s): (/data/nginx/wwwtest.com:/tmp/) in Unknown on line 0
[07-Sep-2021 04:10:45 UTC] PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[07-Sep-2021 04:10:55 UTC] PHP Warning: Unknown: open_basedir restriction in effect. File(/data/nginx/test.com/sleep.php) is not within the allowed path(s): (/data/nginx/wwwtest.com:/tmp/) in Unknown on line 0
[07-Sep-2021 04:10:55 UTC] PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[root@lnmp php-fpm.d]#
再次将配置文件修改回来
[root@lnmp php-fpm.d]# cat /usr/local/php-fpm/etc/php-fpm.d/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
request_slowlog_timeout = 1
slowlog = /usr/local/php-fpm/var/log/www-slow.log
php_admin_value[open_basedir]=/data/nginx/test.com:/tmp/
/重启服务,可以正常使用,也没有产生错误日志。
[root@lnmp php-fpm.d]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/sleep.php -I
HTTP/1.1 200 OK
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 03:25:43 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
[root@lnmp php-fpm.d]# curl -x127.0.0.1:80 test.com/3.php -I
HTTP/1.1 200 OK
Server: nginx/1.17.8
Date: Thu, 19 Aug 2021 03:25:50 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.30
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的子进程最多可以处理这么多请求,当达到这个数值时,它会自动退出。