The understanding of CGI and php-cgi and fast-cgi and PHP-FPM

Source: Internet
Author: User
Tags fpm

Three ways to execute PHP interpreter:


1. mod_php: module form in apache; a single process can handle multiple requests


2. Cgi:Common Gateway Interface, Protocol

php-cgi: 1) The implementation of the CGI protocol to interpret the PHP request; procedure: php request->php-cgi Read and parse

PHP.ini file, initializing environment, Returning processing results based on request parameters


2) a single process can only process one request, and each process needs to read php.ini for parsing, less efficient


3) after modifying the php.ini file, start the PHP-CGI program will not take effect, unable to smooth restart

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "spacer.gif"/> 650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/8D/B4/wKioL1imw1PhbAqfAAE3JxLSiMw742.png "title=" 1.png "alt=" Wkiol1imw1phbaqfaae3jxlsimw742.png "/>


3. Fast-cgi: optimized for CGI protocol, improved performance

php-fpm:1) Implementation of FAST-CGI protocol to parse PHP request, process: php request->php-fpm read

PHP.ini initialization environment, Start a master-> to start multiple worker->master and pass the request

Hand work->php-fpm Dynamic configuration of worker number


2) A single process processes multiple requests by starting multiple php-cgi programs


3) Modify the php.ini file, start a new worker, invoke the new configuration, and implement a smooth restart

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "spacer.gif"/>

650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M00/8D/B6/wKiom1imw3LCwjsXAAJLc-yIyP0495.png "title=" 2.png "alt=" Wkiom1imw3lcwjsxaajlc-yiyp0495.png "/>

This article is from "a horse on the plains" blog, please be sure to keep this source http://huangzp.blog.51cto.com/12434999/1898910

CGI and php-cgi and fast-cgi and php-fpm understanding

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.