I am having issue on PHP where my app is trying to run a php backup file and suddenly getting HTTP Error 500 Code. I have checked the logs and this what it saying.
[Tue Aug 28 14:17:28 2012] [warn] [client x.x.x.x] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://example.com/backup/backup.php
[Tue Aug 28 14:17:28 2012] [error] [client x.x.x.x] Premature end of script headers: backup.php, referer: http://example.com/backup/backup.php
Anyone knows how to fix this? I'm really stuck in here and can't find solution in internet.
Hope anyone could share their knowledge.
Thanks. James
I had the same problem with a different and simple solution.
Problem
I installed PHP 5.6 following the accepted answer to this question on Ask Ubuntu. After using Virtualmin to switch a particular virtual server from PHP 5.5 to PHP 5.6, I received a 500 Internal Server Error and had the same entries in the apache error log:
Cause
Simple: I didn't install the
php5.6-cgi
packet.Fix
Installing the packet and reloading apache solved the problem:
sudo apt-get install php5.6-cgi
if you are using PHP 5.6sudo apt-get install php5-cgi
if you are using a different PHP 5 versionsudo apt-get install php7.0-cgi
if you are using PHP 7Then use
service apache2 reload
to apply the configuration.I had this issue and realized that the file cgi-bin/php-fcgi had no execution rights.
It had 644 mode while is should have 755 mode.
Setting the correct mode was impossible (probably because the file was opened or sth), so I copied that file from another domain directory where it had proper rights already set and that fixed everything.
I had very similar errors in the Apache2 log files:
After checking the wrapper scripts and Apache2 settings, I realized that /var/www/ did not have accordant permissions. Thus the FCGId Wrapper scripts could not be read at all.
For my scenario
chmod -o+rx /var/www
was required of course, since the used SuExec users are not member ofwww-data
user group - and they should not be member for security reasons of course.if you want to install a PHP version < 5.3.0, you must replace
with:
in your
./configure
statement, excerpt from the php.net doc:If this is enabled, the CGI module will be built with support for FastCGI also. Available since PHP 4.3.0
As of PHP 5.3.0 this argument no longer exists and is enabled by --enable-cgi instead. After the compilation the
./php-cgi -v
should look like this:NOTICE THE (cgi-fcgi)
In CentOS releases suexec is compiled to run only in /var/www. If you try to set a DocumentRoot somewhere else you have to recompile it - the error in apache log are: (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server Premature end of script headers: php5.fcgi
As already mentioned this could be happening due to fcgi handler permission issues. If you're using suexec - don't forget to check if apache has this module enabled.