Nginx, FastCGI, php-fpm relationship carding (reprint reference)

Source: Internet
Author: User
Tags nginx server

The relationship between Nginx, FastCGI and PHP-FPM

Also refer to: http://www.cnblogs.com/skynet/p/4173450.html

Preface:When building nginx+php+memached (LPMN) under Linux, nginx.conf needs to be configured fastcgi,php need to install PHP-FPM extension and start the php-fpm daemon, Nginx can parse PHP script. So, what is the rationale behind such a configuration? What is the relationship between Nginx, FastCGI and php-fpm? Bo Master has been such doubts, because can not clear the relationship between Nginx, PHP-FPM, encountered Nginx parsing PHP script, often overwhelmed, the cost of troubleshooting time is very long. Therefore, specially take the time to understand the principle behind this, comb the relationship between Nginx, FastCGI, php-fpm. One, FastCGI? The fastcgi is developed by the CGI (Common Gateway Interface, Universal Gateway Interface) and is between the HTTP server (Nginx, Apache) and the Dynamic scripting language (PHP) Communication Interface。  Remember, fastcgi is just an interface. The advantages of fastcgi: FastCGI adopts C/s structure, can detach the HTTP server from the dynamic Script resolution server (both can be deployed on different servers), allowing the HTTP server to handle static requests and forwarding dynamic requests to the script resolution server, while the script resolution server exclusively handles requests for dynamic scripting. Second, nginx+fastcgiNginx does not support the direct invocation or parsing of external programs, it must be called through fastcgi. After Nginx receives the CGI request, the FastCGI interface initiates one or more daemons to parse the dynamic script on the script parsing server. Third, php-fpmFASTCGI Process Manager/engine: The daemon that actually resolves the dynamic script, initiated by fastcgi. Here, PHP-FPM is a fastcgi process Manager/engine that supports parsing PHP. Summary:    F astcgi is a communication interface between Nginx and PHP, which is actually processed by starting the PHP-FPM process to parse the PHP script., i.e. PHP-FPM equivalent to a dynamic application server, thus implementing the Nginx dynamic parsing PHP. Therefore, if the Nginx server needs to support PHP parsing, you need to add PHP configuration in nginx.conf: Forward the PHP script to the FASTCGI process listening IP address and port (specified in php-fpm.conf). At the same time, PHP installation, you need to turn on the support fastcgi option, and compile and install php-fpm patch/extension, at the same time, need start the PHP-FPM process before you can parse the PHP script that the Nginx forwards via fastcgi.Reference article:installation, configuration and optimization of Nginx and PHP (FastCGI)(The article has very detailed principle analysis and configuration parameter description, highly recommended reading)

Nginx, FastCGI, php-fpm relationship carding (reprint reference)

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.