Window + nginx + php

Source: Internet
Author: User
See bbsbbs. csdn. under the normal configuration of nettopics390803643close, the php-cgi of window does not have multi-thread sub-processes. The following configuration is fastcgi_pass127.0.0.1: 9000. This means that when two php files request resolution at the same time, blocking processing will occur, and the processing time will be. phpb. php, not parallel

See bbs http://bbs.csdn.net/topics/390803643/close normal configuration, window of php-cgi is not multithreading/sub process, the following configuration fastcgi_pass 127.0.0.1: 9000; this means that when the two PHP files request resolution at the same time, blocking will occur, and the processing time will be. phpb. php, not parallel

See bbs

Http://bbs.csdn.net/topics/390803643/close


Under normal configuration, the php-cgi of window does not contain multithreading/sub-processes.


Fastcgi_pass 127.0.0.1: 9000;


This means that when two php files request resolution at the same time, blocking will occur, and the processing time will be a. php + B. php, rather than parallel, it is the serial time.


For example, a. php

Sleep (100); echo 1;

B. php

Echo 2;

Run. php, output in 100 seconds 1. run. run B. php, 2 appears after 100 seconds. suppose... but it does not appear immediately after the operation, because the above configuration is affected, resulting in the resolution of the serial time.





After several hours at google.

Find

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


We know window does not support ?????


There are a lot of people on the Internet who don't know how to deal with it. But I'm testing the server and think it's okay. I just need to start a few php-cgi manually.

As a result.


Start n php-cgi manually.




: Windows does not support multiple nginx threads. You can only manually generate multiple php-cgi
Start "fcgi service"/MIN/D "% batDir % php" php-cgi.exe-B 127.0.0.1: 9000-c "% batDir % php/php. ini"
Start "fcgi service"/MIN/D "% batDir % php" php-cgi.exe-B 127.0.0.1: 9001-c "% batDir % php/php. ini"
Start "fcgi service"/MIN/D "% batDir % php" php-cgi.exe-B 127.0.0.1: 9002-c "% batDir % php/php. ini"
Start "fcgi service"/MIN/D "% batDir % php" php-cgi.exe-B 127.0.0.1: 9003-c "% batDir % php/php. ini"

Start "nginx service"/MIN/D "% batDir % nginx" nginx.exe



Then nginx

Http {
# Window cannot dispatch child processes. Only PHP_FCGI_CHILDREN can be manually configured and does not work in 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;
}


Get a backup server



When configuring a domain name, use forward to the backup 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. If you open four php files at the same time, it can be parsed independently and parsed in parallel. But what about five php files? Please wait for 5th ..........

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.