How to disable output buffering with PHP and nginx

Ben Johnson ben at
Mon Sep 16 17:19:05 UTC 2013


In an effort to resolve a different issue, I am trying to confirm that
my stack is capable of servicing at least two simultaneous requests for
a given PHP script.

In an effort to confirm this, I have written a simple PHP script that
runs for a specified period of time and outputs the number of seconds
elapsed since the script was started.


$start = time();

echo 'Starting concurrency test. Seconds elapsed:' . PHP_EOL;

$elapsed = time() - $start;

echo $elapsed . PHP_EOL;

while ($elapsed < 60) {
	echo time() - $start . PHP_EOL;
	$elapsed = time() - $start;

echo time() - $start . PHP_EOL;


For whatever reason, nginx *always* buffers the output, even when I set

output_buffering = off

in the effective php.ini, *and* I set

fastcgi_keep_conn on;

in my nginx.conf.

Of course, when I request the script via the command-line (php -f), the
output is not buffered.

Is it possible to disable PHP output buffering completely in nginx?

Thanks for any help!


More information about the nginx mailing list