How to disable output buffering with PHP and nginx

itpp2012 nginx-forum at nginx.us
Thu Oct 10 17:35:00 UTC 2013


> Correct.  One nginx process can handle multiple requests, it's one 
> PHP process which limits you.

Not really, use the NTS version of php not the TS, and use a pool as
suggested, e.a.;

    # loadbalancing  php
    upstream myLoadBalancer {
        server 127.0.0.1:19001 weight=1 fail_timeout=5;
        server 127.0.0.1:19002 weight=1 fail_timeout=5;
        server 127.0.0.1:19003 weight=1 fail_timeout=5;
        server 127.0.0.1:19004 weight=1 fail_timeout=5;
        server 127.0.0.1:19005 weight=1 fail_timeout=5;
        server 127.0.0.1:19006 weight=1 fail_timeout=5;
        server 127.0.0.1:19007 weight=1 fail_timeout=5;
        server 127.0.0.1:19008 weight=1 fail_timeout=5;
        server 127.0.0.1:19009 weight=1 fail_timeout=5;
        server 127.0.0.1:19010 weight=1 fail_timeout=5;
#        usage: fastcgi_pass myLoadBalancer;
    }

For a 100mb pipeline this is enough to handle many, many concurrent users.

runcgi.cmd
----------------------------------------------------
@ECHO OFF
ECHO Starting PHP FastCGI...
c:
cd \php

del abort.now

start multi_runcgi.cmd 19001
start multi_runcgi.cmd 19002
start multi_runcgi.cmd 19003
start multi_runcgi.cmd 19004
start multi_runcgi.cmd 19005
start multi_runcgi.cmd 19006
start multi_runcgi.cmd 19007
start multi_runcgi.cmd 19008
start multi_runcgi.cmd 19009
start multi_runcgi.cmd 19010
----------------------------------------------------

multi_runcgi.cmd
----------------------------------------------------
@ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=C:\PHP;%PATH%
set TEMP=\webroot\_other\xcache
set TMP=\webroot\_other\xcache
set PHP_FCGI_CHILDREN=0
set PHP_FCGI_MAX_REQUESTS=10000

:loop
c:
cd \php

C:\PHP\php-cgi.exe -b 127.0.0.1:%1

set errorlvl=%errorlevel%
choice /t:y,3

date /t>>\webroot\_other\fzlogs\ServerWatch.log
time /t>>\webroot\_other\fzlogs\ServerWatch.log
echo Process php-cgi %1 restarted>>\webroot\_other\fzlogs\ServerWatch.log
echo Errorlevel = %errorlvl% >>\webroot\_other\fzlogs\ServerWatch.log
echo:>>\webroot\_other\fzlogs\ServerWatch.log

if not exist abort.now goto loop
----------------------------------------------------

Create a service which starts runcgi.cmd at boot.
After the service is running, assign a very limited user to the service.
ea. always jail nginx and php-cgi separately.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,242895,243597#msg-243597



More information about the nginx mailing list