见bbs
http://bbs.csdn.net/topics/390803643/close
正常的配置情况下,window的php-cgi是不会出现多线程/子进程的,如下配置
fastcgi_pass 127.0.0.1:9000;
这时也就意味着当二个php文件同时请求解析时,就会出现阻塞处理,处理时间就会是a.php+b.php,而不是并行,是串行时间了.
如a.php
sleep(100);echo 1;
b.php
echo 2;
先运行a.php,100秒后输出1.在运行a.php的同时,运行b.php,2却出现在100秒以后.假设...却不是一运行就立刻出现,因为上面的配置受影响导致解析是串行时间了.
在google.翻了几个小时.
找到
The problem is that the PHP_FCGI_CHILDREN environment variable is ignored under windows, therefore php-cgi does not spawn children, and when PHP_FCGI_MAX_REQUESTS is reached the process terminates.
Check on PHP‘s source, file cgi_main.c, around line 1982:
#ifndef PHP_WIN32
/* Pre-fork, if required */
if (getenv("PHP_FCGI_CHILDREN")) {
char * children_str = getenv("PHP_FCGI_CHILDREN");
...
So, php with fast-cgi will **never** work on Windows.
The question is, why is forking disabled under windows?
-------------https://bugs.php.net/bug.php?id=49859-----------
得知window不支持?????
看到网上有很多人不懂怎么处理.而我的是测试服务器,觉得就算了.灵机一动.就手工的开起几个php-cgi等着吧.
于是变通方案时.
手工开起n个php-cgi等着
::window不支持 nginx的多线程,只能手工生成多个php-cgi
start "fcgi服务" /MIN /D "%batDir%php" php-cgi.exe -b 127.0.0.1:9000 -c "%batDir%php/php.ini"
start "fcgi服务" /MIN /D "%batDir%php" php-cgi.exe -b 127.0.0.1:9001 -c "%batDir%php/php.ini"
start "fcgi服务" /MIN /D "%batDir%php" php-cgi.exe -b 127.0.0.1:9002 -c "%batDir%php/php.ini"
start "fcgi服务" /MIN /D "%batDir%php" php-cgi.exe -b 127.0.0.1:9003 -c "%batDir%php/php.ini"
start "nginx服务" /MIN /D "%batDir%nginx" nginx.exe
然后nginx的
http {
#window 不能派生子进程,只能人工配 PHP_FCGI_CHILDREN 在window不起作用的
upstream fastcgi_backend {
server 127.0.0.1:9000;
server 127.0.0.1:9001;
server 127.0.0.1:9002;
server 127.0.0.1:9003;
}
弄一个备用服务器
域名配置时,使用转发到备用服务器
server {
listen 80;
server_name q.qq;
access_log ./../log/q.qq.access.txt;
root d:/web/www;
location ~ \.php$ {
fastcgi_pass fastcgi_backend;
}
}
ok.同时打开4个php是可以独立解析了,并行,但是5个呢?第5个还是要等等吧..........
window+nginx+php-cgi的php-cgi线程/子进程问题