What is the relationship between CGI, FastCGI and PHP_FPM?

不言
Release: 2023-03-23 08:18:02
Original
1826 people have browsed it

最近在使用vagrant搭建php的开发环境。
其中在搭建调试过程中,发现了很多问题(毕竟之前一直在用集成开发环境,一键安装搞定。。)。
进而调查了下CGI FastCGI 与 PHP-FPM 现总结如下:
Copy after login

Summary of a request process

When you accessed index.php using a browser, what exactly did you experience?

What is the relationship between CGI, FastCGI and PHP_FPM?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template