网站暂时中断,fastcgi PHP 通信中止

网站暂时中断,fastcgi PHP 通信中止

我注意到我的 Web 服务器每天都会偶尔出现 1-5 分钟的中断。我检查了 Apache 错误日志,发现以下内容:

[Sun May 10 14:13:19.299784 2015] [fastcgi:error] [pid 2599:tid 139669761148672] [client 174.34.156.130:13278] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)    
[Sun May 10 14:13:19.299855 2015] [fastcgi:error] [pid 2599:tid 139669761148672] [client 174.34.156.130:13278] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"    
[Sun May 10 14:14:00.782370 2015] [fastcgi:error] [pid 2473:tid 139669735970560] [client 82.103.128.63:45704] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)    
[Sun May 10 14:14:00.782432 2015] [fastcgi:error] [pid 2473:tid 139669735970560] [client 82.103.128.63:45704] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"    
[Sun May 10 14:14:19.124915 2015] [fastcgi:error] [pid 2473:tid 139669786326784] [client 188.138.118.184:34672] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)    
[Sun May 10 14:14:19.124962 2015] [fastcgi:error] [pid 2473:tid 139669786326784] [client 188.138.118.184:34672] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"    
[Sun May 10 14:14:33.978792 2015] [fastcgi:error] [pid 2473:tid 139669643650816] [client 82.103.128.63:11778] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)    
[Sun May 10 14:14:33.978853 2015] [fastcgi:error] [pid 2473:tid 139669643650816] [client 82.103.128.63:11778] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"    
[Sun May 10 14:14:34.380783 2015] [fastcgi:error] [pid 2598:tid 139669744363264] [client 174.34.156.130:46479] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)    
[Sun May 10 14:14:34.380843 2015] [fastcgi:error] [pid 2598:tid 139669744363264] [client 174.34.156.130:46479] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"    
[Sun May 10 14:15:19.518501 2015] [fastcgi:error] [pid 2598:tid 139669685614336] [client 76.164.194.74:28967] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)    
[Sun May 10 14:15:19.518575 2015] [fastcgi:error] [pid 2598:tid 139669685614336] [client 76.164.194.74:28967] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"    
[Sun May 10 14:16:19.404843 2015] [fastcgi:error] [pid 2598:tid 139669727577856] [client 50.23.94.74:23923] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)    
[Sun May 10 14:16:19.404894 2015] [fastcgi:error] [pid 2598:tid 139669727577856] [client 50.23.94.74:23923] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"    
[Sun May 10 14:17:19.210294 2015] [fastcgi:error] [pid 2598:tid 139669769541376] [client 85.17.156.99:15068] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)
[Sun May 10 14:17:19.210368 2015] [fastcgi:error] [pid 2598:tid 139669769541376] [client 85.17.156.99:15068] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"

我查看了 syslog 和 php5-fpm.log,但没有发现任何错误。

在我的 php.ini 中我已经设置:error_log = /var/log/php_errors.log 但是当 log_errors 处于开启状态时,这个文件并没有生成。

我也尝试设置 error_log = syslog,但 syslog 中没有报告有关 PHP 的错误。

知道我可以做什么来解决这个问题吗?我使用的是 Ubuntu 服务器 15.04 x64、Apache 2.4.10、PHP-FPM 5.6

答案1

请检查 /var/log/messages 文件中的错误,您可以在那里找到与服务器相关的错误。

它是否每天在特定时间发生,那么您可能想查找当时运行并导致问题的 cron 进程。

您需要检查当时的服务器负载,如果当时的服务器负载正在增加,那么您需要检查导致服务器负载的进程。

答案2

尝试在<VirtualHost>块中设置这些指令:

FcgidMaxRequestsPerProcess 1000
FcgidIOTimeout 3600
FcgidConnectTimeout 3600
FcgidIdleTimeout 3600
FcgidProcessLifeTime 3600
FcgidBusyTimeout 3600

注意 RAM 使用情况。如果此方法有效,您可能需要减少 RAM 使用量并重新测试。

相关内容