見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不支持??
???
看到網上有非常多人不懂怎么處理.而我的是測試server,認為就算了.靈機一動.就手工的開起幾個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
域名配置時,使用轉發到備用server
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個還是要等等吧..........