FastCGI:只有一个特定的文件“通信服务器中止:读取失败”

相关问题: FastCGI和Apache 500错误间歇性

该解决scheme不适合我。


问题:

我有一台Laravel 5.1应用程序(在其他服务器上生产,没有任何问题),运行在新的Ubuntu 14.04服务器上,使用Apache 2.4.7和PHP,通过PHP-FPM运行

只要在应用程序中不调用某个文件,一切工作正常:

$compiledPath = __DIR__.'/cache/compiled.php'; if (file_exists($compiledPath)) { require $compiledPath; // this causes a "500 Internal Server Error" } 

这是一个由框架自动创build的Laravel特定文件,用于加快速度(所以这不是我的代码中的错误),它确实存在,我有完全的访问权限。 它的大小约为600kB 。 当我删除它,一切工作正常。 但是,当我告诉Laravel再次创build它,然后点击应用程序的任何path时,出现以下日志条目的“500内部服务器错误”:

[fastcgi:error] [pid 14334](104)通过peer重置连接:[client xxx.xxx.xxx.xxx:41395] FastCGI:与服务器通信“/ var / www / clients / client1 / web1 / cgi-bin / php5-fcgi-yyy.yyy.yyy.yyy-80-domain.com“中止:读取失败

[fastcgi:error] [pid 14334] [client xxx.xxx.xxx.xxx:41395] FastCGI:从服务器收到的不完整标题(0字节)“/ var / www / clients / client1 / web1 / cgi-bin / php5- fcgi-yyy.yyy.yyy.yyy-80-domain.com”

[fastcgi:error] [pid 14334](104)通过peer重置连接:[client xxx.xxx.xxx.xxx:41395] FastCGI:与服务器通信“/ var / www / clients / client1 / web1 / cgi-bin / php5-fcgi-yyy.yyy.yyy.yyy-80-domain.com“中止:读取失败

[fastcgi:error] [pid 14334] [client xxx.xxx.xxx.xxx:41395] FastCGI:从服务器收到的不完整标题(0字节)“/ var / www / clients / client1 / web1 / cgi-bin / php5- fcgi-yyy.yyy.yyy.yyy-80-domain.com”

我试过了:

我在上面提到的相关问题中尝试了解决scheme,这也代表了我可以find的关于这个问题的其他大部分build议:使用常见的PHP-FPM设置来分配更多的资源。 被接受的答案也提到完全放弃FastCGI的select,但我不想去那里。 所以我玩弄了价值观,但没有运气。

因为我是唯一使用它的服务器上没有任何负载,所以我真的怀疑这是可用资源(这是一个VPS 12GB RAM)的问题。 这可能与文件大小有关吗? 这是唯一的PHP文件。

我可以在2个不同的服务器上使用相同的configuration重现问题。 它在具有FastCGI的Apache 2.2的Ubuntu 12.04服务器上没有发生。

我目前的configuration:

PHP-FPM:

 pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 5 pm.max_requests = 0 

 <IfModule mod_fastcgi.c> ... Alias /php5-fcgi /var/www/.... FastCgiExternalServer /var/www/.... -idle-timeout 300 -socket /var/lib/php5-fpm/web1.sock -pass-header Authorization </IfModule> 

php.ini中

 memory_limit = 512M output_buffering = on 

如果PHP只在特定的源文件上失败,最可能的原因是像Xcache,APC或eAccelerator这样的PHP代码加速器(操作码caching)对文件有问题。 这可能是由于加速器或PHP本身的错误。

您可以尝试通过PHP命令行界面( php-cli命令)运行脚本,因为PHP CLI不使用任何加速器。