Php+fastcgi+nginx Dynamic Request Processing configuration

Source: Internet
Author: User
Tags fpm


Nginx does not support calls to external programs, so calls to external programs must be implemented via the FASTCGI interface to handle client dynamic page requests.

The English language of CGI is all called Common Gateway Interface (Public Gateway Interface), which is the bridge of Nginx and dynamic scripting programs. Nginx generates a thread from the FastCGI interface by sending a dynamic request to the wrapper process in fastcgi,fastcgi. The request is sent to the script interpreter to run, and then the original socket will explain the results of the run after the original path back to Nginx, then the result of Nginx to the client.

Nginx sends a dynamic request to wrapper through a socket file socket, using the TCP protocol. The wrapper accepts the request via the CGI interface. This allows the webserver and interpreter to develop independently, thus avoiding errors and crashes and security issues caused by the interpreter calling the server's interface directly. It also enables Nginx to concentrate on static page requests and forward dynamic requests. Instead, install the script interpreter in a server, which puts the pressure on the server to be apportioned.


CGI is developed as a patch for PHP programs, installing PHP first installs the libraries it relies on, and then adds options such as support for CGI--enable-fpm--enable-cgi when compiling configuration parameters. Compile the PHP extension module. The Phpize tool in PHP is used to generate the Configure file when the module is compiled. It is assumed that the Configure file could not be generated when Phpize was executed because the AUTOCONF package was not installed.

The configuration file for the PHP-FPM process is/usr/local/php/etc/php-fpm.conf capable of configuring the PHP-FPM.

Nginx Configuration Support fastcgi:

Location ~ \.php${

root HTML;

Fastcgi_pass Unix:/tmp/fastcgi.soke//Connect via socket file and CGI, this file is set in php-fpm.conf

Fastcgi_index index.php;

Fastcgi_param script_filename html$script_file_name; Setting the number of references

Include Fastcgi_params; Import the fastcgi parameter configuration file. This file is generated on its own initiative during nginx installation.

}


Php+fastcgi+nginx Dynamic Request Processing configuration

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.