Gateway php-cgi fastcgi PHPFPM

Source: Internet
Author: User
Tags fpm


On the understanding of the gateway, one sentence is: As a translator, abstract out a way to reach the resources.

This refers to the use of the translator to reach the resources, can include the Conversion Protocol (HTTP/FTP) to obtain the other end of the gateway with the client using a different protocol server resources, can also include through the gateway to the database to send query statements to obtain dynamic data, can also include through the gateway and different networks to communicate. In short, resources are obtained through the gateway.

After understanding the macro concept of the gateway, let's look at the classification of the gateway:

    • Protocol gateways: Protocol conversions between Networks of different protocols.
    • Application Gateway: Convert one data format of a service into another data format for the service, enabling data exchange. For example, two hosts with different e-mail protocols are communicating with each other through an e-mail gateway.
    • Security Gateway: The most common Security gateway is the packet filter, in fact, the original address of the packet, the destination address and port number, the network protocol authorization. By filtering the information, the licensed packets are transmitted through the gateway, and the packets that do not have permission are intercepted or even discarded.

The gateways above are both client-and server-side gateways, which are located in the middle of the server and client. There is also a common gateway, an application server, that combines the target server with the gateway in a single server. For example, the client connects to the server via HTTP, and the server sends the request through a gateway application programming interface to the application running on the server.

The first popular Application Gateway API is the Universal Gateway Interface (Common Gateway interface,cgi). CGI is a standard set of interfaces . For example, when the server needs to request the resources of the gateway, it passes the required data to it (usually the entire request, including the URL, the query string, the header of the HTTP request, etc.). The gateway then returns the response data to the server and the server returns the data to the client.

So, the nature of CGI is: A protocol that includes input requests, referrals, and responses.

But there is one obvious problem with CGI: A new process is raised for each CGI request, and the overhead is limiting the performance of those using the CGI server. So a new kind of cgi--fastcgi appeared.

The FastCGI interface simulates CGI, but runs as a persistent daemon. First, fastcgi initiates a master, parses the configuration file, initializes the execution environment, and then starts multiple workers. When the request comes in, master passes it to a worker, and then immediately accepts the next request.

The above-mentioned CGI and fastcgi are protocols that are not related to a particular language.

So what is php-cgi? There are 2 main types of statements online:

    • PHP interpreter is php-cgi,php-cgi is just a CGI program, does not carry out process management.
    • PHP-CGI is the fastcgi manager that comes with PHP.

The personal understanding is: php-cgi is PHP comes with the fastcgi manager, the management process name is php-cgi, it should be the name of the coincidence.

But the php-cgi's shortcomings are:

    • php-cgi after changing the php.ini configuration, you need to restart the php-cgi for the new php.ini to take effect, not to smooth the restart.
    • Directly kill the php-cgi process, PHP will not be able to run. (PHP-FPM does not have this problem, the daemon will smoothly regenerate new child processes.) )

In summary, the birth of the PHP-FPM, but also a realization of the FASTCGI protocol procedures. PHP-FPM provides a better way to manage PHP processes, effectively controlling memory and processes, and smoothing the overloading of PHP configurations.

Reference: How to explain the relationship between CGI, FastCGI and php-fpm in a popular way?
Concept understanding: cgi,fastcgi,php-cgi and PHP-FPM
HTTP Authoritative Guide 8.1 8.2 8.3

Gateway php-cgi fastcgi PHPFPM

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.