Home > Backend Development > PHP Tutorial > A brief discussion on the principles and concepts of cgi, fastcgi and php-fpm

A brief discussion on the principles and concepts of cgi, fastcgi and php-fpm

little bottle
Release: 2023-04-06 09:56:02
forward
2721 people have browsed it

This article mainly talks about the principles and concepts of cgi, fastcgi and php-fpm. Interested friends can learn about it.

A brief discussion on the principles and concepts of cgi, fastcgi and php-fpm

cgi

cgi is the common gateway interface definition. When the web server receives the request for /index.php, it will start the corresponding CGI program, which is the PHP parser. Next, the PHP parser will parse the php.ini file, initialize the execution environment, process the request, return the processed result in the format specified by CGI, and exit the process. The web server then returns the results to the browser.

fastcgi

fastcgi is a protocol. Realize the management process and improve cgi performance. Standard cgi will parse php.ini for each request and initialize the environment, which is a waste of time; fastcgi starts the master process, parses the configuration file, initializes the environment, and then starts multiple worker processes; when the request comes, the master Pass it to the workers for processing; if there are not enough workers, a few will be added in advance, and if there are many workers, a few will be stopped.

php-fpm

is a program that implements the fastcgi protocol. After modifying php.ini, the php-cgi process cannot restart smoothly. php-fpm's handling mechanism for this is that new workers use new configurations, and existing workers can rest after processing the work at hand. This mechanism is used to smooth the transition.

Related tutorials: PHP video tutorial

The above is the detailed content of A brief discussion on the principles and concepts of cgi, fastcgi and php-fpm. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template