Php+fastcgi+nginx Configure PHP Run environment _php instance

Source: Internet
Author: User

CGI English is all called Common Gateway Interface (Public Gateway Interface), is nginx and dynamic Scripting Program Bridge, nginx through the fastcgi interface to send dynamic request to fastcgi, The wrapper process in fastcgi generates a thread, passes the request to the script interpreter, and then returns the resulting path to the Nginx via the original socket, nginx the result to the client.

Nginx sends a dynamic request to wrapper through a socket file socket, using a TCP protocol. Wrapper accepts requests via a CGI interface. This allows the Web server and the interpreter to be fully developed independently, thus avoiding errors and crashes and security problems that can result from an interpreter calling the server's interface directly. It also allows Nginx to concentrate on static page requests and forward dynamic requests, while the script interpreter is installed on another server, and the server's pressure is apportioned.

CGI is developed as a patch for PHP programs, installing PHP to first install the libraries it relies on, and then adding options such as CGI support--ENABLE-FPM--enable-cgi when compiling configuration parameters. To compile the extension module for PHP, you need to use the Phpize tool in PHP to generate the Configure file at the module compile time, if the Configure file cannot be generated when running phpize, because the autoconf package is not installed.

The configuration file for the PHP-FPM process is/usr/local/php/etc/php-fpm.conf, and the PHP-FPM can be configured accordingly.

Nginx Configuration Support fastcgi:

Location ~ \.php${

             root html;

             Fastcgi_pass  Unix:/tmp/fastcgi.soke  //through the socket file and CGI to establish a connection, the file in the php-fpm.conf set

             fastcgi_index index.php;

             Fastcgi_param script_filename html$script_file_name; set parameters

             include fastcgi_params;//import fastcgi parameter profile, This file is generated automatically when Nginx is installed.

                   }

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.