cgi, fast-cgi, php-cgi, php-fpm reprint Detailed



Reprinted from: https://segmentfault.com/q/1010000000256516

First, CGI is doing it? CGI is to ensure that data transfer over the web server is a standard format to facilitate the CGI program writers.

web server (such as nginx) only distributor of the content. For example, if the request /index.html, then the web server will go to the file system to find the file, sent to the browser, here is the distribution of static data. Well, if the request is now /index.php, according to the configuration file, nginx know that this is not a static document, you need to find PHP parser to handle, so he put this request after simple processing to the PHP parser. Nginx which will pass the data to the PHP parser it? url have it, they have to have it query string, POST data should have, HTTP header no less ... Ok, CGI is to provide for the transfer of data which is transmitted to the rear handle protocol this request in what format. Think about it, the user you are using in the PHP code came from.

When the web server is received /index.phpafter this request, will start corresponding CGI program, here is the PHP parser. Next PHP parser will parse the php.ini file, initializing the execution environment, and then processes the request, then the provisions of the CGI format specified return the results of treatment, quit the process. web server sends the results back to the browser.

Well, CGI is a protocol, it does not matter what with the process. That fastcgi what is it? Fastcgi CGI program is used to improve performance.

Improve performance, then performance problems CGI program in which it? "PHP parser will parse the php.ini file, initializing the execution environment", it is here. Standard CGI these steps for each request (not busy Leia! Start the process very tired to say!), So the time to process each time will be longer. This is obviously unreasonable thing! So Fastcgi is how to do it? First, Fastcgi will first open a master, parsing the configuration file, initializing the execution environment, and then start multiple worker. When a request came, master passed to a worker, and then immediately accept the next request. This will avoid duplication of work, efficiency naturally high. And when the worker is not enough, master can start pre-configured according to several worker waiting; of course, too much idle worker, also stopped a number, thus improving performance, but also saves resources. This is the management of the process of fastcgi.

That PHP-FPM what is it? Fastcgi is a realization of the program, is the official PHP received.

As we all know, PHP interpreter is php-cgi. php-cgi just a CGI program, he himself can only parse the request and returns the results, not process management (emperor, Chenqie really can not ah!) so there have been some can be scheduled php-cgi process procedures, For example, isolated from lighthttpd spawn-fcgi. Well, PHP-FPM is such a stuff, after a long period of development, has been gradually recognized by everyone (you know, a few years ago, but everyone complained about the poor stability of PHP-FPM), are increasingly popular.

Well, the last to come back to your question.
Some say the Internet, fastcgi is a protocol, php-fpm implement this agreement

Correct.

Some said, php-fpm is fastcgi process manager to manage the process fastcgi

Correct. php-fpm of managed objects is php-cgi. But can not say php-fpm is fastcgi process manager, as said earlier, is a fastcgi protocol, such a process does not seem to exist, even if there is php-fpm can not manage his (at least for now). Some said, php-fpm is a kernel patch php

I used to be right. Since the very beginning of php-fpm not included in the PHP core inside, to use this feature, you need to find the same source version of php-fpm patch the kernel, then compile. Later PHP core with integrated PHP-FPM is more convenient to use --enalbe-fpmthe compiler parameters.

Some said that after changes to php.ini configuration file, no way to smooth restart, so was born php-fpm

Yes, after modifying the php.ini, php-cgi process really is no way to smooth restart. php-fpm processing mechanism for this is the new configuration with the new worker, the worker already processed can live hand to recover from, such a smooth transition mechanism.

Some have even said PHP-CGI is bundled with PHP FastCGI manager, that this is the case why they get hold of a php-fpm

wrong. php-cgi just interpreter PHP script only.



Reprinted from: https://segmentfault.com/q/1010000000256516

First, CGI is doing it? CGI is to ensure that data transfer over the web server is a standard format to facilitate the CGI program writers.

web server (such as nginx) only distributor of the content. For example, if the request /index.html, then the web server will go to the file system to find the file, sent to the browser, here is the distribution of static data. Well, if the request is now /index.php, according to the configuration file, nginx know that this is not a static document, you need to find PHP parser to handle, so he put this request after simple processing to the PHP parser. Nginx which will pass the data to the PHP parser it? url have it, they have to have it query string, POST data should have, HTTP header no less ... Ok, CGI is to provide for the transfer of data which is transmitted to the rear handle protocol this request in what format. Think about it, the user you are using in the PHP code came from.

When the web server is received /index.phpafter this request, will start corresponding CGI program, here is the PHP parser. Next PHP parser will parse the php.ini file, initializing the execution environment, and then processes the request, then the provisions of the CGI format specified return the results of treatment, quit the process. web server sends the results back to the browser.

Well, CGI is a protocol, it does not matter what with the process. That fastcgi what is it? Fastcgi CGI program is used to improve performance.

Improve performance, then performance problems CGI program in which it? "PHP parser will parse the php.ini file, initializing the execution environment", it is here. Standard CGI these steps for each request (not busy Leia! Start the process very tired to say!), So the time to process each time will be longer. This is obviously unreasonable thing! So Fastcgi is how to do it? First, Fastcgi will first open a master, parsing the configuration file, initializing the execution environment, and then start multiple worker. When a request came, master passed to a worker, and then immediately accept the next request. This will avoid duplication of work, efficiency naturally high. And when the worker is not enough, master can start pre-configured according to several worker waiting; of course, too much idle worker, also stopped a number, thus improving performance, but also saves resources. This is the management of the process of fastcgi.

That PHP-FPM what is it? Fastcgi is a realization of the program, is the official PHP received.

As we all know, PHP interpreter is php-cgi. php-cgi just a CGI program, he himself can only parse the request and returns the results, not process management (emperor, Chenqie really can not ah!) so there have been some can be scheduled php-cgi process procedures, For example, isolated from lighthttpd spawn-fcgi. Well, PHP-FPM is such a stuff, after a long period of development, has been gradually recognized by everyone (you know, a few years ago, but everyone complained about the poor stability of PHP-FPM), are increasingly popular.

Well, the last to come back to your question.
Some say the Internet, fastcgi is a protocol, php-fpm implement this agreement

Correct.

Some said, php-fpm is fastcgi process manager to manage the process fastcgi

Correct. php-fpm of managed objects is php-cgi. But can not say php-fpm is fastcgi process manager, as said earlier, is a fastcgi protocol, such a process does not seem to exist, even if there is php-fpm can not manage his (at least for now). Some said, php-fpm is a kernel patch php

I used to be right. Since the very beginning of php-fpm not included in the PHP core inside, to use this feature, you need to find the same source version of php-fpm patch the kernel, then compile. Later PHP core with integrated PHP-FPM is more convenient to use --enalbe-fpmthe compiler parameters.

Some said that after changes to php.ini configuration file, no way to smooth restart, so was born php-fpm

Yes, after modifying the php.ini, php-cgi process really is no way to smooth restart. php-fpm processing mechanism for this is the new configuration with the new worker, the worker already processed can live hand to recover from, such a smooth transition mechanism.

Some have even said PHP-CGI is bundled with PHP FastCGI manager, that this is the case why they get hold of a php-fpm

wrong. php-cgi just interpreter PHP script only.

Guess you like

Origin www.cnblogs.com/applelife/p/11955528.html