PHP-FPM 集合

查看php-fpm的进程个数

ps -fe |grep "php-fpm"|grep "pool"|wc -l

查看每个php-fpm占用的内存大小

ps -ylC php-fpm --sort:rss

查看单个php-fpm进程消耗内存的明细

pmap $(pgrep php-cgi | head -1)

记一次网站访问不正常

因为我的机器开发了大量的端口..然后我就把一部分取消了,然后网站就不能访问了

现象

  • 网站一直504(首先我怀疑就是php-fpm)

检查php-fpm

sudo systemctl status php-fpm
sudo systemctl restart php-fpm

修改socket模式为port

还是效果一样

测试静态资源是否能访问

确实能访问.. 排除了nginx的锅

https://iluoy.com/uploads/images/20180111/5a563f33494f6_35.png

查看php-fpm日志

sudo tail -f /var/log/php7.2-fpm/error.log

[08-Dec-2018 00:36:28] WARNING: [pool www] child 4757, script '/data/www-data/iluoy.com/public/index.php' (request: "GET /index.php") executing too slow (1.262518 sec), logging
[08-Dec-2018 00:36:28] NOTICE: child 4757 stopped for tracing
[08-Dec-2018 00:36:28] NOTICE: about to trace 4757
[08-Dec-2018 00:36:28] NOTICE: finished trace of 4757

查看框架日志

很奇怪 框架居然没有日志

查看nginx日志

sudo tail -f  /var/log/nginx/iluoy.com/error.log

2018/12/08 00:36:45 [error] 4275#4275: *83513 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /data/www-data/iluoy.com/vendor/sentry/sentry/lib/Raven/Stacktrace.php on line 295
PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /data/www-data/iluoy.com/vendor/sentry/sentry/lib/Raven/Stacktrace.php on line 297" while reading response header from upstream, client: 114.246.3.167, server: iluoy.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "iluoy.com"

这就是说明问题是在 php-fpm到php的中间环节出了问题.. 突然想起 刚刚关闭了3306 端口.. 于是想起了项目最开始是用公网的3306端口访问的

所以这个时候.就开放公网3306就好了...

总结

  • 这里需要把把mysql修改为内外的3306访问