最近在使用vagrant搭建php的开发环境。 其中在搭建调试过程中,发现了很多问题(毕竟之前一直在用集成开发环境,一键安装搞定。。)。 进而调查了下CGI FastCGI 与 PHP-FPM 现总结如下:
When you accessed index.php using a browser, what exactly did you experience?
Is it a little clearer after reading this picture? Let’s explain it in detail below.
When you enter the URL address to access index.php, your browser (client) will send a request to your server (nginx, apache, etc.), but the server can only process static resources such as html, like Dynamic resources such as php and jsp cannot be processed by the server, so a specific parser is required to process them. So how do the server and the parser communicate (contact)? CGI is used. They communicate through CGI. After communication, you need to use PHP-FPM to parse the php file. After the parsing is completed, it is returned to the server, and the server returns to the browser (client). In this way, the request process is over. .
So:
CGI is a protocol for data exchange between Web Server and Web Application.
FastCGI: Same as CGI, it is a communication protocol, but it has some optimizations in efficiency than CGI.
PHP-CGI: It is the interface program of PHP (Web Application) to the CGI protocol provided by Web Server.
PHP-FPM: It is an interface program for the FastCGI protocol provided by PHP (Web Application) to the Web Server. It also provides relatively intelligent task management.
Reference materials
Illustration of the relationship between CGI, FastCGI and PHP-FPM
Related recommendations:
php-fpm - How to view Configuration file path of running php_fpm?
The above is the detailed content of What is the relationship between CGI, FastCGI and PHP_FPM?. For more information, please follow other related articles on the PHP Chinese website!