見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個還是要等等吧..........