Nginx-I have seen other people's windowsphp have such configuration. What are the advantages of this configuration?

Source: Internet
Author: User
Tags nginx reverse proxy
{Code...} certainly omitted a lot... it seems to be for php multi-process
http {upstream php_processes {    server 127.0.0.1:9001 weight=1;    server 127.0.0.1:9002 weight=1;}server {        ## Regular PHP processing.        location ~ \.php$ {            try_files  $uri =404;            fastcgi_pass   php_processes;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;            include        fastcgi_params;        }}}

Of course, I omitted a lot... it seems that it is for php multi-process

Reply content:
http {upstream php_processes {    server 127.0.0.1:9001 weight=1;    server 127.0.0.1:9002 weight=1;}server {        ## Regular PHP processing.        location ~ \.php$ {            try_files  $uri =404;            fastcgi_pass   php_processes;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;            include        fastcgi_params;        }}}

Of course, I omitted a lot... it seems that it is for php multi-process

This is nginx configuration. Are you sure this is a PHP configuration file?

First, this is the nginx configuration file, which means.phpThe end request is sent to the fastcgi interpreter;
Secondly, php-fpm is a fastcgi Process Manager, supporting multi-process and dynamically increasing or decreasing the number of processes;
Again, if there are multiple different php-fpm on the network, you can configure nginx for multi-machine load balancing;
Finally, the advantage of this configuration is that if a node fails, nginx can forward the request to another node to achieve high availability.

This is the configuration of nginx Reverse proxy.

This is the nginx configuration file, not the PHP configuration file. the php configuration file is php. ini.

Isn't this nginx configuration? How to change to php?

Thumbs up for the upstairs !!! Hahaha. it is indeed nginx Reverse proxy configuration.

This is the server load balancer configuration, and the proxy is located in the location.

The above answers did not mention the key points.

upstream php_processes {    server 127.0.0.1:9001 weight=1;    server 127.0.0.1:9002 weight=1;}

Why do we need to open two ports, 9001 and 9002, that is, two executable threads?
Example:


  

If there is only one thread number, the code will wait for the execution of test. php, and test. php will wait until the execution of the php file ends ......
So, the "deadlock ...... Wait for an unlimited amount of time, and then get down after 30 seconds of timeout.
So WNMP must be configured in this way.
This configuration is only used for local testing code.
If you want to be more professional, we do not recommend that you use Windows or just give two processing threads.
(The following part is the general default Nginx configuration. I will not explain it)

The answer upstairs is positive,upstreamIt is the Nginx server load balancer configuration, which means that requests are distributed to two ports according to the same weight. The intention is to process tasks by multiple processes. The first is to increase the concurrency, the second is to prevent the occurrence of various locks such as file locks.

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.