Php+fastcgi+nginx Configuring PHP Runtime Environment _php

Source: Internet
Author: User
Keywords Php fastcgi nginx
The CGI English is all called Common Gateway Interface (Public Gateway Interface), is the Nginx and the dynamic Script program bridge, Nginx sends the dynamic request through the FastCGI interface to FastCGI, The wrapper process in fastcgi generates a thread, passes the request to the script interpreter to execute, and then passes the original socket to explain the result of the execution after the original path is returned to Nginx, after which the result is given 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 Web server and the interpreter to be fully developed independently, thus avoiding errors and crashes and security issues caused by the interpreter calling the server's interface directly. It also allows Nginx to concentrate on static page requests and forward dynamic requests, while installing the script interpreter on another server, which puts 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 CGI support--ENABLE-FPM--enable-cgi when compiling configuration parameters. To compile the PHP extension module, you need to use the PHP phpize tool to generate the module compile-time configure file, if run Phpize cannot generate configure file, because there is: no autoconf package 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 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 during Nginx installation.                   }
  • 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.