What exactly does CGI, FastCGI, and php_fpm matter?

Source: Internet
Author: User

The development environment for PHP was recently built using vagrant. In the process of building debugging, found a lot of problems (after all, has been in the integrated development environment, one-click installation done.) )。 Further investigation of the next CGI FastCGI and PHP-FPM is summarized as follows:

Summary of one request process

What happened when you visited index.php using a browser?

Is it a little clearer to read this picture? Below is the specific explanation 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 handle static resources such as HTML, such as php,jsp these dynamic resource server is not processed, So you need a specific parser to deal with, then the server and the parser is how to communicate (contact)? Use CGI, they communicate through the CGI, communication after the need to use PHP-FPM to parse the PHP file, after the completion of the resolution, return to the server, the server back to the browser (client), so that a request process is over.

So:

  • CGI is a protocol for data exchange between Web Server and Web application.

  • FastCGI: The same as CGI, is a communication protocol, but it is more efficient than CGI to do some optimization.

  • PHP-CGI: Is the interface program for the CGI protocol provided by PHP (Web application) to Web Server.

  • PHP-FPM: is an interface program for the FastCGI protocol provided by PHP (Web application) to the Web Server, and additionally provides relatively intelligent task management.

Resources
CGI, fastcgi, and php-fpm relationship plots

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.