-If the request is now/index.php, according to the configuration file, Nginx know this does not. is a static file, need to find a PHP parser to deal with, then he will make this request simple processing and handed over to the PHP parser. What data will the Nginx send to the PHP parser? URLs, query strings, POST data, HTTP headers, and so on, CGI is the protocol that specifies which data to pass, in what format, to the rear to process the request. When the Web server receives the/index.php request, it launches the corresponding CGI program, which is the parser for PHP. The PHP parser then parses the php.ini file, initializes the execution environment, then processes the request, and then returns the processed result in a format specified by the CGI, exiting the process. The Web server then returns the results to the browser. FastCgi is what FastCgi is a protocol, FASTCGI is used to improve the performance of CGI programs. So what is the performance problem with CGI programs? "The PHP parser parses the php.ini file, initializes the execution environment," and here it is. The standard CGI performs these steps for each request, so it takes longer to process each request. So how did FastCgi do it? First, FastCgi initiates a master, parses the configuration file, initializes the execution environment, and then starts multiple workers. When the request comes in, master passes it to a worker, and then immediately accepts the next request. This avoids duplication of labor, and efficiency is naturally high. And when the worker is not enough, master can pre-boot several workers according to the configuration and so on, of course, the idle worker too much, will also stop some, this improves the performance, also saves the resources. This is FastCgi's management of the process.PHP-FPM is an implementation of the FASTCGI program, is included in the official PHP. PHP interpreter is php-cgi, it is only a CGI program, can only parse the request, return the results, will not process management. So there are some programs that can dispatch the php-cgi process, such as spawn-fcgi, php-fpm separated by LIGHTHTTPD. The management object of PHP-FPM is php-cgi. PHP-CGI is just a program that explains PHP scripts, fastcgi is a protocol, PHP-FPM implements this Protocol
FastCgi and PHP-FPM