Detailed PHP installation mode---cgi,fastcgi,php-fpm,mod_php,mod_cgi,mod_fcgid

Source: Internet
Author: User

1. CGI

CGI is a universal Gateway interface, the HTTP server uses such an interface program to communicate with "other programs" (such as the PHP interpreter program), this "other program" can be written in any computer language, it through the CGI interface from the HTTP server to get input, And then the result of the operation through the CGI interface to the HTTP server, and the HTTP server to send this result to the browser.

The advent of CGI makes the web from static to dynamic, as the web becomes more and more popular, many sites need to have dynamic pages, in order to cross with the browser. The shortcomings of the CGI approach are also becoming more prominent. Because HTTP is generating a dynamic page, the system must start a new process to run the CGI program, and the fork is a time-consuming and resource-intensive task. That's where the fastcgi comes in.

CGI uses the fork and execution approach, and each request requires a new CGI program for processing, which results in poor performance.

2. FASTCGI

FastCGI is a resident memory CGI, which is actually the process management of CGI programs, accepting requests through the master process, distributing them to worker processes, and prefork worker processes, reducing the overhead of CGI process creation, initialization, and destruction, thereby improving performance.

3. mod_php

Mod_php is Apache's built-in PHP interpretation module, using Prefork way, do not need additional process to do communication and application interpretation, obviously mod_php than mod_cgi this way performance is much better, but the disadvantage is to bind the application and the HTTP server together, In addition, each Apache process needs to load mod_php regardless of whether the request is handling static content or dynamic content, which results in a waste of memory, a decrease in efficiency, and the need to restart the Apache server for php.ini file changes to take effect, which makes it impossible to make smooth configuration changes.

4. php-fpm

PHP-FPM is used in conjunction with the Nginx program, PHP-FPM is actually a fastcgi protocol to strengthen the implementation, has been included in the PHP kernel, can be enabled by the--ENABLE-FPM compilation option, PHP-FPM supports configuration smoothing changes (by fork new worker processes), good performance and high memory efficiency, which is why NGINX+PHP-FPM's configuration combination overrides apache+mod_cgi and apache+mod_php.

5. Mod_fcgid

It is Apache's fastcgi implementation, the performance is also very good, in the Apache 2.4 later version of the support.

Reference reading:

Http://httpd.apache.org/mod_fcgid/

Http://www.openlogic.com/wazi/bid/209956/mod_php-vs-FastCGI-vs-PHP-FPM-for-Web-Server-Scripting

http://www.eschrade.com/page/why-is-fastcgi-w-nginx-so-much-faster-than-apache-w-mod_php/

http://serverfault.com/questions/6733/php-what-are-the-advantages-of-fastcgi-over-mod-php

Introduction, comparison, and performance data of mod_php and mod_fastcgi and PHP-FPM

http://download.csdn.net/detail/ztianfu/4350292

Detailed PHP installation mode---cgi,fastcgi,php-fpm,mod_php,mod_cgi,mod_fcgid

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.