Can Windows PHP-FPM serve multiple simultaneous requests?

不想你离开。 提交于 2020-01-01 15:52:30

问题


I'm currently using nginx and PHP FastCGI but that arrangement suffers from the limitation that it can only serve one HTTP request at a time. (See here.) I start PHP from the Windows command prompt by doing;

c:\Program Files\PHP>php-cgi -b 127.0.0.1:9000

However there is another way to run PHP know as "Fast CGI Process Manager" (PHP-FPM).

When running on Windows 7 behind nginx, can PHP-FPM handle multiple simultaneous HTTP requests?


回答1:


I ended up with this solution: you simply start several php-cgi processes and bind them to different ports, and you need to update nginx config:

http {

    upstream php_farm {
        server 127.0.0.1:9000 weight=1;
        server 127.0.0.1:9001 weight=1;
        server 127.0.0.1:9002 weight=1;
        server 127.0.0.1:9003 weight=1;
    }

    ...

    server {
      ...
      fastcgi_pass   php_farm;
    }

}

For the sake of convenience, I created simple batch files.

start_sandbox.bat:

@ECHO OFF
ECHO Starting sandbox...

RunHiddenConsole.exe php\php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini
RunHiddenConsole.exe php\php-cgi.exe -b 127.0.0.1:9001 -c php\php.ini
RunHiddenConsole.exe php\php-cgi.exe -b 127.0.0.1:9002 -c php\php.ini
RunHiddenConsole.exe php\php-cgi.exe -b 127.0.0.1:9003 -c php\php.ini

RunHiddenConsole.exe mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone --console

cd nginx && START /B nginx.exe && cd ..

and stop_sandbox.bat:

pstools\pskill php-cgi

pstools\pskill mysqld

pstools\pskill nginx

as you can see, there are 2 dependencies: pstools and runhiddenconsole.exe



来源:https://stackoverflow.com/questions/15819351/can-windows-php-fpm-serve-multiple-simultaneous-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!