Windows PHP-FPM可以同时处理多个请求吗? [英] Can Windows PHP-FPM serve multiple simultaneous requests?

查看:414
本文介绍了Windows PHP-FPM可以同时处理多个请求吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用 nginx PHP FastCGI ,但是这种安排受到限制,因为它一次只能服务一个HTTP请求. (请参见此处.)我从Windows命令提示符处启动PHP;

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

不过,还有另一种运行PHP的方式称为快速CGI流程管理器"(PHP-FPM).

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

在nginx之后的Windows 7上运行时,PHP-FPM是否可以处理多个同时的HTTP请求?

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

推荐答案

我最终得到了这个解决方案:您只需启动几个php-cgi进程并将它们绑定到不同的端口,就需要更新nginx config:

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 ..

stop_sandbox.bat:

pstools\pskill php-cgi

pstools\pskill mysqld

pstools\pskill nginx

如您所见,有2个依赖项: pstools runhiddenconsole.exe

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

这篇关于Windows PHP-FPM可以同时处理多个请求吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆