我有一个运行 Apache/2.2.22(Debian)、PHP 5.6.17 作为 FPM 和 MySQL 5.6.25 的服务器。
该项目使用名为 Redaxo 的 CMS 运行(我认为它不是那么重要,但我还是会告诉你)。在 Redaxo 中,有些功能需要一些时间(例如,删除缓存并重建需要 1-2 分钟)。在此期间,当其他用户访问网站时,FPM 会崩溃,500 Internal Server Error
我不得不多次重新加载页面,直到服务器错误消失并且该过程完成。
我注意到,只有当网站上同时有太多用户并且执行大量操作时,才会发生这种情况。
10 个用户同时浏览 = 没有问题
10 个用户同时浏览,同时删除缓存 = 每个人都会出现 500 错误。
我通过禁止除我之外的所有人访问网站(.htaccess 拒绝/允许使用 ip)检查了这一点。然后我进行了繁重的操作,没有问题。一旦多个人再次访问该网站,问题又出现了。
会是什么情况?你需要我提供什么信息?
这些值在php-fpm.conf
[global]
pid = /run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
emergency_restart_threshold = 0
include=/etc/php5/fpm/pool.d/*.conf
这些值是在项目特定的中设置的(未注释)fpm.conf
[projectname]
user = projectname
group = projectname
listen = /var/run/php5-fpm-projectname.sock
listen.owner = projectname
listen.group = projectname
listen.mode = 0660
pm = dynamic
pm.max_children = 150
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 30
chdir = /
php_value[upload_max_filesize] = 128M
php_value[max_post_size] = 128M
php_value[max_execution_time] = 180
php_value[memory_limit] = 256M
如果脚本失败,它会对 MySQL 和文件创建产生很大影响吗?但它太大了,所以我不确定是否应该在这里发布它?或者它是否是问题所在?
apache 错误日志说的是
[Tue Feb 09 10:54:01 2016] [error] [client {IP}] (104)Connection reset by peer: FastCGI: comm with server "/fcgi-bin-php5-fpm-projectnmae" aborted: read failed
[Tue Feb 09 10:54:01 2016] [error] [client {IP}] FastCGI: incomplete headers (0 bytes) received from server "/fcgi-bin-php5-fpm-projectnmae"
或这个
[Tue Feb 09 11:00:46 2016] [error] [client {IP}] FastCGI: incomplete headers (0 bytes) received from server "/fcgi-bin-php5-fpm-projectname"
[Tue Feb 09 11:00:48 2016] [error] [client {IP}] (104)Connection reset by peer: FastCGI: comm with server "/fcgi-bin-php5-fpm-projectname" aborted: read failed
fpm-log
上面写着。当然,时间总是不同的
[10-Feb-2016 09:40:59] WARNING: [pool projectname] child 10970 exited on signal 7 (SIGBUS) after 50.186611 seconds from start
[10-Feb-2016 09:40:59] NOTICE: [pool projectname] child 11092 started
有时会有这样的警告
[09-Feb-2016 11:00:41] WARNING: [pool projectname] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 6 total children
[09-Feb-2016 11:00:42] WARNING: [pool projectname] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 7 total children
答案1
我以前也见过类似的错误。可能与 PHP 缓存模块有关。请尝试以下操作:
;php-fpm.conf: pm.max_spare_servers = 30 pm.max_requests = 200 pm.start_servers = 30 ;启用 slowlog - 它为您提供可读的堆栈跟踪 slowlog = /var/log/php-fpm-slow.log request_slowlog_timeout = 10s listen.backlog = -1
然后检查 PHP 安装中的缓存模块。我见过启用 APC 的安装中出现 SIGBUS 问题。针对 APC 模块尝试以下操作:
#apc.ini apc.stat = 0 #或者禁用它: apc.启用= 0