Apache 2.2 + mod_fcgid + PHP 5.4: (104) Connection reset by peer

Posted by Michele Piccirillo on Server Fault See other posts from Server Fault or by Michele Piccirillo
Published on 2012-10-04T16:23:41Z Indexed on 2013/11/03 10:00 UTC
Read the original article Hit count: 336

On a Debian 6 VPS, I'm running PHP 5.4 via mod_fcgid on a couple of different virtual hosts, managed by Virtualmin GPL. At random, I get 500 Internal Server Errors; restarting Apache brings everything back to normality.

Examining the logs, I find messages of this kind:

[Thu Oct 04 15:39:35 2012] [warn] [client 173.252.100.117] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Thu Oct 04 15:39:35 2012] [error] [client 173.252.100.117] Premature end of script headers: index.php

Any ideas about what is happening?

UPDATE: I found a similar question and the author reported to have solved the problem disabling APC. I tried following the advice, but I'm still getting the same errors.

VirtualHost configuration

SuexecUserGroup "#1000" "#1000"
ServerName example.com
DocumentRoot /home/example/public_html
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/example/public_html>
    Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
    allow from all
    AllowOverride All
    AddHandler fcgid-script .php
    AddHandler fcgid-script .php5
    FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php
    FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php5
</Directory>

<Directory /home/example/cgi-bin>
    allow from all
</Directory>

RemoveHandler .php
RemoveHandler .php5
IPCCommTimeout 61
FcgidMaxRequestLen 1073741824

php5.fcgi

#!/bin/bash
PHPRC=$PWD/../etc/php5
export PHPRC
umask 022
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=99999
export PHP_FCGI_MAX_REQUESTS
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php5-cgi

Package versions

webmin-virtual-server/virtualmin-universal 3.94.gpl-2
apache2/squeeze 2.2.16-6+squeeze8
libapache2-mod-fcgid/squeeze 1:2.3.6-1+squeeze1
php5 5.4.7-1~dotdeb.0 
php5-apc 5.4.7-1~dotdeb.0

© Server Fault or respective owner

Related posts about apache2

Related posts about php