I have a website in php that works with a solr indexation server, based on CodeIgniter.
We got a lot of new content, so we flushed the database, and had to reindex the content (about 168,000 elements). I created a script to index the contents by slices of 500 – when the script finishes, we launch the next indexing.
It works perfectly on my local test environment, but on production I get this 500 error:
[Thu Dec 02 ...] [error] [client IP] Premature end of script headers: index.php
There is absolutely nothing in my php.log, just the apache error_log that returns it. I've seen it happen on other pages of the website once or twice, but it was during this indexing.
Any ideas?
This error is usually (sometimes) caused by the FastCGI setup of the FcgidIOTimeout
directive (old name: IPCCommTimeout
).
That is the number of seconds for IO timeout, default is 40 seconds. Timeout means that
"The FastCGI application must begin generating the response within this period of time. Increase this directive as necessary to handle applications which take a relatively long period of time to respond."
You can try to solve it putting this into your vhost.conf:
<IfModule mod_fcgid.c>
# 5 minutes for IO timeout, default is 40 seconds
FcgidIOTimeout 300
</IfModule>
You can increase it as you need and then restore the original value once the reindexing process is complete.
There is a good list about the possibilities on Liquid Web's KB;
Upgrading or downgrading to a different version of PHP can leave residual options in the httpd.conf. Check the current version of PHP using php -v on the command line and search for any lines mentioning another version in the httpd.conf. If you find them, comment them out, distill the httpd.conf and restart apache.
The RLimitCPU and RLimitMEM directives in the httpd.conf may also be responsible for the error if a script was killed due to a resource limit.
A configuration problem in suEXEC, mod_perl, or another third party module can often interfere with the execution of scripts and cause the error. If these are the cause, additional information relating to specifics will be found in the apache error_log.
If suphp’s log reaches 2GB in size or larger you may see the premature end of scripts headers error. See what the log contains and either gzip it or null it. Restart apache and then deal with any issues that the suphp log brought to light. The suphp log is located at: /usr/local/apache/logs/suphp_log
The script’s permissions may also cause this error. CGI scripts can only access resources allowed for the User and Group specified in the httpd.conf. In this case, the error may simply be pointing out that an unauthorized user is attempting to access a script.
http://www.liquidweb.com/kb/apache-error-premature-end-of-script-headers/
If I were in the same situation, I'd check the permissions first then continue with 3 and 4.
I was also receiving this error message in etc/httpd/logs/error_log after a 500 Internal server error trying to load a website.
For me, the solution was permissions - had to chmod 755 the file. I had created the file as a higher access level user than the one that was "loading" the site on the server.
its also can because of using PHP APC Extension in a wrong way.
so first remove apc.so from php.ini restart apache and test it again :)
What's your error_level in php? The error-message you get there inside the log is often result of a simple PHP-error, but the server is setup to do not deliver error-messages to the client for security-reasons. By this the message is not very helpful, it could be everything.
I had this problem and after struggling for more than 5 hours, I disabled xcache and everything went back to normal, error disappeared!
u forgot to add content-type header in the response which is a must have http header when hosting on apache2
header('Content-Type: text/html');
I had the same problem, just restart the apache server and it works