Php - Bulk post 500 Apache Internal Server Error - php

I've a script which send just a lot of data in json format
by post.
Up to about 10Mb (data are put into a flat file) of data the script works great but
if the load is higher I get from apache 500 Internal Server Error.
I peeped into apache log file I get
[Wed Jan 19 17:26:41 2011] [error] [client ip] Premature end of script headers: index.php
[Wed Jan 19 17:26:41 2011] [debug] mod_deflate.c(615): [client ip] Zlib: Compressed 632 to 385 : URL /index.php
Do you have any idea about it ?
Bye.

Premature end of script headers
This message means the PHP script died before outputing any content-type to apache. If you have ob_* functions activated it could be any error on your PHP script, or a timeout, check your set-time-limit parameter in PHP for timeouts.
Check as well that your exception handling output the correct content type if you want to output an error message.
To check all parameters that can have an impact you must check the timeout parameters and the size limits ones. Here are some of them:
Apache:
LimitRequestBody
PHP:
post_max_size
upload_max_filesize
max_input_time
max_execution_time
and maybe memory_limit as well

Related

mod_fcgid: read data timeout in 31 seconds

I am getting 2 errors as mentioned below.
[Fri Jan 09 04:10:23 2015] [warn] [client 188.165.15.22] mod_fcgid: read data timeout in 31 seconds
[Fri Jan 09 04:10:23 2015] [error] [client 188.165.15.22] Premature end of script headers: index.php
I checked this Premature end of script headers: index.php, mod_fcgid: read data timeout in 61 seconds also. But I do not have any file like /etc/httpd/conf.d/fcgid.conf to edit.
Does anybody have any idea?
I don't think that there might be any issue with php script as it as been working fine from past 1 year. Now all of sudden it has stopped working.
My Apache version is 2.2.22 and PHP Version 5.3.10-1ubuntu3.13
Content of fcgid.conf:
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
FcgidConnectTimeout 20
FcgidIOTimeout 2000
</IfModule>
You can increase the timeout as indicated in the other post:
FcgidIOTimeout 600
But since you are on Ubuntu, you'll find the relevant configuration file here:
/etc/apache2/mods-available/fcgid.conf
For me it was 41 seconds and it was coming from the httpd.conf file of the site
# /etc/apache2/sites-available/website.com.conf
<VirtualHost ipv4:80 [ipv6]:80>
IPCCommTimeout 600 #increased from 41
</VirtualHost>
If you're using FcgidCmdOptions, see answer to this question - mod_fcgid read timeout from pipe, end of script output before headers, multiple versions of PHP . In short - global options are ignored for the program specified in FcgidCmdOptions, so all timeouts have to be configured directly in this instruction.

(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server

I am using a Ubuntu 12 Server with Plesk 12 running on it.
I get the following-error in irregular distances which ends up with an Internal Server error!
When I reload the page it's the same problem but after about a minute the error disapears.
[time] [error] [client x.x.x.x] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://host.co/test
[time] [error] [client x.x.x.x] Premature end of script headers: index.php, referer
I have tried a lot (checking my permissions, changing the FcgidBusyTimeout, …) but it has become even worse (my subjective grading).
Can you please try to increase following setting on your server under fcgid.conf file.
FcgidIdleTimeout 3600
FcgidIdleScanInterval 480
FcgidBusyTimeout 1800
FcgidBusyScanInterval 480
FcgidZombieScanInterval 12
FcgidErrorScanInterval 12

500 Internal Server Error - Error logs do not show anything significant

First of all, thank you for your time in reading this :)
I am managing a server which runs apache2 and mod_fcgi which host a few sites via Virtual Hosts. Some sites are straight PHP, the others are all WordPress. The WordPress sites are all functioning great, however, any other site throws up a 500 Internal Server Error when you try to access them.
If you navigate to a non-php file on the web directory (like an image) it will display, but any .php file throws up this error.
The Apache2 error log shows nothing.
When I tail the error log of the site, I get this:
[Wed May 22 15:12:15 2013] [warn] [client x.x.x.x] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed May 22 15:12:15 2013] [error] [client x.x.x.x] Premature end of script headers: php-fcgi-wrapper
[Wed May 22 15:12:15 2013] [debug] mod_deflate.c(615): [client x.x.x.x] Zlib: Compressed 612 to 377 : URL /fcgi-bin/php-fcgi-wrapper/index.php
The root of the website is located in /var/www/site1/
I have quadrouple-checked my permissions and ownerships.
I have increased more memory for PHP.
I tried looking at the php.log file, but nothing is being written.
Can anyone point anything else out that could be causing this?
Thank you!
I don't have the time at the moment to back up my cgi-conflict suggestion, but it occurred to me that you may be using php short tags, when the server doesn't allow it. Wordpress I believe uses full open tags which would explain why it works.
Instead of using:
<? //some php code
?>
Try:
<?php //some php code
?>
Are you using short tags? This could be your issue.

PHP maximum execution time

In my Plesk 11, PHP 5.4.7. Apache/2.4.3 system, when I make cron jobs I get this error from error.log file.
[Tue Mar 19 21:33:18 2013] [warn] [client 88.44.55.66] mod_fcgid: read data timeout in 45 seconds
[Tue Mar 19 21:33:18 2013] [error] [client 88.44.55.66] Premature end of script headers: index.php
So I checked for execution time with this:
echo ini_get('max_execution_time');
I got this value: 1560000
It doesn't seem a timeout problem but I get timeout error?
Answer for the future reference:
Edit /etc/httpd/conf.d/fcgid.conf file with vim.
Change FcgidIOTimeout 45 to FcgidIOTimeout 600.
Restart Apache.
Then Fast CGI timeout will be solved.
That's a mod_fcgid timeout, not a PHP timeout. Take a look at the mod_fcgid documentation to find out how to change it, especially at FcgidIOTimeout.
Cron scripts if build correctly should not be run through apache. Your error shows that you are running into a timeout set by mod_fcgi.
If you access it through http in your cronjob, then it will work as a webpage request and then it may be affected by apache timeout because apache is involved in the process. You can run the php script directly with an absolute path using php interpreter to bypass apache

Proxy blocking uploads

I am using uploadify to upload files on a site. Every once and a while I get these errors in my server log:
[Tue Jun 26 09:24:45 2012] [error] [client ipaddress] Handler for x-httpd-php5 returned invalid result code 70007
[Tue Jun 26 09:25:17 2012] [error] [client ipaddress] Handler for x-httpd-php5 returned invalid result code 70014
After some googling I have found that is probably caused by a person using a proxy when they are on our site.
I read somewhere online that this may help:
pass your apache log in debug mode using the directive LogLevel
I don't know what that means but i can pass it along to my webhost.
Is there any way to try and detect a proxy so I can warn the user that the upload may fail?
Any other ideas on how to handle this?
Has anyone else had this issue with uploading files via a proxy?

Categories