Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache 500 Error with PHP Fun

So I am running a PHP script on my godaddy (don't hate me) virtual server which I am expecting to take around 5 minutes to finish executing. The script is CURLing pages but never holds more than 1 page at a time (it is done in a loop reusing the same variable). I modified my php5.ini file to the following:

max_execution_time = 600
max_input_time = 120
memory_limit = 64M 

I verified through phpinfo that the ini file changes had taken effect, however I am getting an Apache 500 error after 120 seconds. Here is the error log for this time:

[Wed Jul 11 22:08:52 2012] [warn] [client **.**.**.***] mod_fcgid: read data timeout in   120 seconds
[Wed Jul 11 22:08:52 2012] [error] [client **.**.**.***] Premature end of script headers: test.php

If anyone has any ideas on why I might be getting these errors or any suggestion on things to try I would appreciate the help. I did notice an option in the php settings set at 120, but I'm not sure if it would have an effect: realpath_cache_tt

I also set a time limit in the .php file: set_time_limit( 600 );

Thanks in advance.

UPDATE: Here is what I tried in the .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
<IfModule mod_fcgid.c>
IPCCommTimeout  7200
</IfModule>

The causes an Apache 500 error on any page load. I also disabled FastCGI but the issue is still occuring.

RESOLVED RobB suggested the following: IPCCommTimeout 7200 Which should have worked however due to my godaddy shared hosting it is not allowed. Time to find a new hosting service.

like image 745
cazzer Avatar asked Jul 12 '12 05:07

cazzer


1 Answers

I'm not sure of the handling with this issue on GoDaddy but the normal resolution would be as follows:

The issue that you are experiencing is due to FastCGI executing a PHP script but it doesn't generate a response within the default IO timeout (120 seconds), which results in the 500 Internal Server Error.

Try editing the default VirtualHost conf file, typically located at /etc/apache2/sites-available/default and add this directive inside the <VirtualHost> context:

<IfModule mod_fcgid.c>
   IPCCommTimeout  7200
</IfModule>

After saving the modification, restart apache2 with this command: sudo /etc/init.d/apache2 restart.

From what I've been able to determine from GoDaddy is that the maximum time limit is 120 seconds for PHP/FastCGI in shared hosting, which can not be increased by the client. I would suggest contacting their support for assistance and hopefully their reputation won't serve up and you'll be able to get help.

Update: Not sure if it will help but you could try changing from FastCGI to PHP5 in your hosting control center (Settings > File Extension > php5).

like image 69
Robert Avatar answered Sep 19 '22 12:09

Robert