If you’re running Apache with the mod_fcgid module to let your PHP scripts be handled in a seperate module, you can run into this annoying little bug in the mod_fcgid 2.2.x implementations.
The problem: mod_fcgid: read data timeout in xx seconds
First, check if you have the mod_fcgid module that is causing these problems.
# rpm -qa |grep -i mod_fcgid mod_fcgid-2.2-11.el5
Apparently, any 2.2.x branche has this bug.
The problem exists if any VirtualHost does not have the IPCommTimeout value. If there’s a VirtualHost where this setting is not defined, it will reset the configuration globally back to the default of 40 seconds, resulting in the following error you Apache’s error logs.
[warn] mod_fcgid: read data timeout in 40 seconds Premature end of script headers: php-cgi, referer: [snip]
And they will throw a 500 Internal Server Error in your access logs.
"GET /path/to/url HTTP/1.1" 500 537
The solution: IPCommTimeout in every virtual host
The solution sucks if you have many (manually controlled) virtual hosts, but you have to define the IPCommTimeout option in every Virtual Host on the server. If one is missing, it will reset the config of that parameter to the default serverwide. So place the following codeblock in every Virtual Host you have.
<IfModule mod_fcgid.c> IPCCommTimeout 360 IPCConnectTimeout 360 </IfModule>
The values above are expressed in seconds.