How to disable output buffering with PHP and nginx
Ben Johnson
ben at indietorrent.org
Mon Oct 7 19:22:15 UTC 2013
On 9/16/2013 1:19 PM, Ben Johnson wrote:
> Hello,
>
> 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.
>
> -----------------------------------------------
> <?php
>
> $start = time();
>
> echo 'Starting concurrency test. Seconds elapsed:' . PHP_EOL;
> flush();
>
> $elapsed = time() - $start;
>
> echo $elapsed . PHP_EOL;
> flush();
>
> while ($elapsed < 60) {
> echo time() - $start . PHP_EOL;
> flush();
>
> sleep(5);
>
> $elapsed = time() - $start;
> }
>
> echo time() - $start . PHP_EOL;
> flush();
>
> -----------------------------------------------
>
> 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!
>
> -Ben
>
Sorry to bump this topic, but I feel as though I have exhausted the
available information on this subject.
I'm pretty much in the same boat as Roger from
http://stackoverflow.com/questions/4870697/php-flush-that-works-even-in-nginx
. I have tried all of the suggestions mentioned and still cannot disable
output buffering in PHP scripts that are called via nginx.
I have ensured that:
1.) output_buffering = "Off" in effective php.ini.
2.) zlib.output_compression = "Off" in effective php.ini.
3.) implicit_flush = "On" in effective php.ini.
4.) "gzip off" in nginx.conf.
5.) "fastcgi_keep_conn on" in nginx.conf.
6.) "proxy_buffering off" in nginx.conf.
nginx 1.5.2 (Windows)
PHP 5.4.8 Thread-Safe
Server API: CGI/FastCGI
Is there something else that I've overlooked?
Perhaps there is someone with a few moments free time who would be
willing to give this a shot on his own system. This seems "pretty
basic", but is proving to be a real challenge.
Thanks for any help with this!
-Ben
More information about the nginx
mailing list