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.
##Nginx FastCGI operating principle (Recommended learning: PHP video tutorial)
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!