<!DOCTYPE html>
window+nginx+php-cgi的php-cgi线程/子进程问题
window+nginx+php-cgi的php-cgi线程/子进程问题
Friday, October 30, 2015
5:42 PM
window+nginx+php-cgi的php-cgi线程/子进程问题
发布者:明媚,
时间:2014-06-17 03:22:36
见bbs
正常的配置情况下,window的php-cgi是不会出现多线程/子进程的,如下配置
fastcgi_pass 127.0.0.1:9000;
如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不支持?????
于是变通方案时.
手工开起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 {
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个还是要等等吧..........
#经yau测试,php不可解析.
已使用 Microsoft OneNote 2016 创建。