The relationship between fast-cgi CGI Nginx PHP-FPM
FAST-CGI is developed by CGI, is the interface between HTTP server (Http,nginx, etc.) and dynamic scripting language (Php,perl, etc.), just an interface, he is in the form of a socket (can be a file socket, can also be IP SOCKET), you can separate the HTTP server from the dynamic Script resolution server (which can be deployed on different servers), allow the HTTP server to handle static requests and forward dynamic requests to the script resolution server, and the script resolution server to handle the requests of dynamic scripts.
PHP-FPM: is a fastcgi process manager, also a script parsing server
A PHP request is handled by an nginx to explain the relationship between several people
1.nginx server automatically loads the FASTCGI process manager when it starts
The 2.FASTCGI Process Manager (PHP-FPM) initializes itself and initiates multiple CGI interpretation processes (php-cgi) and waits for connections from Nginx
3. When the Nginx server receives the need to parse PHP, the request is forwarded to the FastCGI interface (socket), the FASTCGI process Manager receives the request and selects and connects a CGI interpreter, and the Nginx server sends the CGI environment variable and standard input to the CGI interpreter ( i.e. php-cgi)
4.FastCGI child process (php-cgi) returns standard output and error information from the same connection to Web Server after processing is complete. When the fastcgi child process closes the connection, the request is processed to completion. The fastcgi child process then waits and processes the next connection from the FASTCGI process Manager (running in Web server).
The above is the process of fastcgi processing requests, so what about CGI?
It says that CGI is just a communication port between the HTTP server and the Dynamic scripting language, and when he receives a processing request from the HTTP server, the script parser is started to parse. He has a great drawback, every time you receive a request from the HTTP server, you have to restart the script parsing server to perform the parsing (reload various environment variables, configuration, etc.), after the end of the parse to exit, cycle, the efficiency is very low, and fast-cgi equivalent to a resident and in-memory CGI to a large extent improves server performance
PS: Add a little Tomcat
We all know that Tomccat is actually a servelt, it is actually a script parsing server, the main parsing Java program, unlike Php-frm, it is a multi-threaded way to handle requests, relatively efficient and less occupy system resources
This is my network of articles and books on the explanation to do a summary, there is a lack of hope that you correct, we learn together ha!
Related article: http://www.cnblogs.com/wanghetao/p/3934350.html
fast-cgi CGI nginx php-fpm Relationship (ext.