Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
add comment

2 Answers

I've just finished configuring my new server :

  • Slackware 14.0
  • Apache 2.4.3 (custom compile)
  • PHP 5.4.7 (custom compile)
  • mod_fcgid 2.3.7 (custom compile)
  • Webmin / virtualmin last versions

I've got same error as you, I've started to make sure mod_fcgi is ok by testing a fcgi script :

#!/usr/bin/perl
use CGI::Fast;

while (my $q = CGI::Fast->new) {
print("Content-Type: text/plain\n\n");
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";

You can test that just to isolate your problem and also see your global apache error_log (not the virtualhost).

share|improve this answer
add comment

Probably your PHP is processing long to respond and it hits max_execution_time set in php.ini. In this case, PHP simply terminates execution and close connection. That's why you are seeing connection reset by peer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.