Home  >  Article  >  Backend Development  >  Does nginx support php?

Does nginx support php?

(*-*)浩
(*-*)浩Original
2019-10-12 11:00:193902browse

FastCGI (Fast Common Gateway Interface, Fast Common Gateway Interface) is a scalable, high-speed interface (or protocol) for communication between HTTP server and dynamic scripting language.

Does nginx support php?

##Nginx FastCGI operating principle (Recommended learning: PHP video tutorial)

Does nginx support php?

Nginx does not support direct calling or parsing of external programs. All programs (including PHP) must be called through the FastCGI and uwsig interfaces.

FastCGI interface calls socket under Linux (unix sockt or ip:port form). In order to call a CGI program, a FastCGI wrapper is also needed. The wrapper is bound to a fixed socket, such as a port or file socket.

When Nginx sends a CGI request to this socket, through the FastCGI interface, the wrapper receives the request and then derives a new thread. This thread calls the interpreter or external program to process the script and reads the return data. ;Then the wrapper passes the returned data to Nginx through the FastCGI interface and along the fixed socket.

Finally Nginx sends the returned data to the client.

PHP-FPM

FastCGI interface mode starts one or more daemon processes on the script parsing server to parse dynamic scripts. These processes are the FastCGI process manager. Or FastCGI engine.

PHP-FPM is the FastCGI engine that supports PHP. PHP-FPM is a third-party FastCGI process manager, developed as a patch for PHP, so it needs to be compiled together with the PHP source code during installation, which means that PHP-FPM is compiled into the PHP kernel.

The main advantage of FastCGI is to separate dynamic languages ​​​​from HTTP Server, so Nginx and PHP/PHP-FPM are often deployed on different servers to share the pressure on the front-end Nginx server and make Nginx dedicated Processes static requests and forwards dynamic requests, while the PHP/PHP-FPM server specializes in parsing PHP dynamic requests.

The above is the detailed content of Does nginx support php?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn