I often see these things, but I can't understand the information I found on the Internet. Concept understanding: CGI, FastCGI, PHP-CGI and PHP-FPM is best to give a chestnut! Thank you for reading these things frequently, but you cannot understand the information you have found on the Internet.
Concept: CGI, FastCGI, PHP-CGI and PHP-FPM
It is best to give a chestnut!
Thank you.
Reply content:
I often see these things, but I can't understand the information I found on the Internet.
Concept: CGI, FastCGI, PHP-CGI and PHP-FPM
It is best to give a chestnut!
Thank you.
CGI is an interface rule used to establish the communication mode between the HTTP server and the dynamic processing program.
FastCGI is an implementation of CGI. it allows a CGI process to process multiple requests by making the CGI processing program resident process, reduces the time and resource consumption for repeatedly starting CGI programs.
Php-cgi is a FastCGI used to provide PHP program processing.
Php-fpm (FastCGI Process Manager) is a management tool for managing FastCGI processes on the FastCGI program.
Php-cgi is a single process. when a php-cgi is enabled to process requests, only one request can be processed at a time, and other requests are queued.
Php-fpm manages multiple FastCGI processes so that requests can be concurrently sent to multiple FastCGI processes for simultaneous processing.
It can be simply understood that php-fpm manages multiple php-cgi
For example, a request is sent from the client to the Nginx server and then processed by the PHP program:
Requests are sent to the Nginx server. The Nginx server sends requests to the php-fpm according to the configuration. However, Nginx and php-fpm are the products of the two companies, if they make sure that they can read the information sent by the other party? This is because they follow the CGI rules during design.
After receiving the request, php-fpm finds an idle process in the FastCGI process managed by the user to process the request.
In addition, Nginx can also be connected to php-cgi, but php-cgi does not have a process management module, but is a single process.
According to Yin Chuan's answer, the relationship between FastCgi and PHP-fpm