4

I have been trying to flush the output of certain scripts to the browser on demand, but they do not work on our productions server.

For instance, I tried running the "Phoca Changing Collation tool" (find it on Google) and I don't see any output until the script finishes executing.

I've tried immediately flushing the buffer on other script that works fine on any server but this one using the following code:

echo "something";
ob_flush();
flush();

Setting "ob_implicit_flush(1);" doesn't help either.

The server is Apache 2.2.21 with PHP 5.2.17 running on Linux. You can see our php.ini file here if that will help: http://www.smallfiles.org/download/1123/php.ini.html

This isn't the only problem we are having with the server ignoring in-script directives. The server also ignores timeout coding such as:

ini_set('max_execution_time', 900*60);

AND

set_time_limit(86400);

Script always times out at the php.ini default.

Doesn't seem to matter if script is executed in IE or Firefox.

7
  • FYI, set_time_limit() is ignored if your PHP install is running in safe-mode. Note the warning on that page. Commented Jul 3, 2012 at 22:49
  • Is PHP running as a CGI or Apache module? And as Mike said, is gzip compression enabled using mod_deflate? Commented Jul 3, 2012 at 23:01
  • Mike, tried "ini_set('zlib.output_compression_level', 'Off');" and checked that it is "Off" in the php.ini file. The code "apache_setenv('no-gzip', 1);" causes a fatal error so tried uploading a .htaccess file with the "mod_gzip_on No" directive. None of this helps. Commented Jul 3, 2012 at 23:23
  • drew010, Tried running Apache as fcgi and suphp, but same results. Commented Jul 3, 2012 at 23:24
  • jedwards, Neither line of code works. PHP is not in safe mode as this is a production server. Commented Jul 3, 2012 at 23:25

2 Answers 2

1

Solved this mystery. Both of them.

To fix the output buffer problem, I needed to turn off gzip compression inside the .htaccess file, though I wish I could just do it in-script.

Here's what you should put in your .htaccess file:

<IfModule mod_gzip.c>
    mod_gzip_on  No
</IfModule>

SetEnv no-gzip dont-vary

To fix the script terminating without error, I checked my Apache log files and found it wasn't PHP but in the Apache configuration: The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed

Had to increase the Apache timeout to prevent this error from making it look like my scripts were timing out. Enabling KeepAlive in Apache also helped to resolve the issue once and for all.

Hope this helps someone and thanks for everyone elses' help!

Sign up to request clarification or add additional context in comments.

Comments

0

You could be loading an incorrect php.ini file, as it tends to change based on directory.

To check your loaded php.ini file, write: echo php_ini_loaded_file();, which will give you the directory it's in. see php.net

if that fails, see serverfault.com for the server stackexchange site.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.