How to disable output buffering with PHP and nginx

B.R. reallfqq-nginx at yahoo.fr
Mon Oct 7 21:57:49 UTC 2013


Hello,


On Mon, Oct 7, 2013 at 5:35 PM, Francis Daly <francis at daoine.org> wrote:

> Run the fastcgi server like this:
>
>   env -i php-cgi -d cgi.fix_pathinfo=0 -q -b 9009
>
> Use an nginx config which includes something like this:
>

​I would recommend being careful about that experiment since there is a
high probability that Ben uses php-fpm (it's actually the recommended way
compared to the old FastCGI + php-cgi and the related issues).
First Ben​

​should ensure that php-cgi and php-fpm shares the exact same ini
configuration. That's a common caveat... :o)
​

> ==
>   location = /php {
>     fastcgi_param SCRIPT_FILENAME /usr/local/nginx/test.php;
>     fastcgi_pass 127.0.0.1:9009;
>   }
> ==
>
> Then do something like
>
>   tcpdump -nn -i any -A -s 0 port 9009
>
> while also doing a
>
>   curl -i http://127.0.0.1:8080/php
>
> and look at the network traffic from the fastcgi server.
>
> If you don't see a five-second gap between the two different response
> packets, it is being buffered before it gets to nginx.
>

​That's the best way of proceeding since it uses the exact environment PHP
will be using for production-ready code. Wireshark may be used to read pcap
dumps with a nice graphical presentation.​

Now make whichever please-don't-buffer changes seem useful in the php code
> and in the fastcgi server configuration. When you can see non-buffered
> output getting to nginx, then you know the non-nginx side is doing what
> you want. So now you can start testing nginx configuration changes;
> and you can share the exact non-nginx configuration you use, so that
> someone else can copy-paste it and see the same problem that you see.
>
> (Change 127.0.0.1:9009 to be whatever remote server runs your fastcgi
> server, if that makes it easier to run tcpdump.)
>
> Good luck with it,
>

​I share the wish. :o)
Please share the results of every step with us for we could help you
further.​
---
*B. R.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20131007/4177a7c8/attachment.html>


More information about the nginx mailing list