PHP: CGI, FASTCGI, php-fpm, mod_php, mod_cgi, mod_fcgid can be confused when some common concepts are not noticed.
1. CGI is a Common Gateway Interface. the HTTP server uses this interface program to communicate with other applications (such as PHP interpreter programs). because CGI adopts the fork and execution method,
Each request requires a new CGI program for processing, resulting in low performance.
2. FASTCGI is the resident memory CGI. it is actually the process management of the CGI program. it accepts requests through the master process and distributes the requests to the worker process. It can also prefork worker processes, reduces the overhead of CGI process creation, initialization, and destruction to improve performance.
3. mod_php is the built-in php interpretation module of apache. it uses the prefork method and does not require additional processes for communication and application interpretation. Obviously, mod_php has much better performance than mod_cgi, however, the disadvantage is that the application and the HTTP server are bound together. In addition, every Apache process needs to load mod_php, regardless of whether the request processes static content or dynamic content, which leads to a waste of memory, efficiency is reduced. In addition, php. changes to the INI file can take effect only after the apache server is restarted, which makes smooth configuration changes impossible.
4. php-fpm is a commonly used program with nginx. php-fpm is actually an enhanced implementation of the FASTCGI protocol and has been incorporated into the PHP kernel, you can use the -- enable-fpm compilation option to enable it. php-fpm supports smooth configuration changes (through the fork new worker process) with good performance and high memory usage efficiency, this is why the configuration combination of nginx + php-fpm replaces apache + mod_cgi and apache + mod_php.
5. mod_fcgid is the fastcgi implementation of apache and has good performance. it is supported in versions later than apache 2.4.
Refer:
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
By cstopery