Php+fastcgi+nginx Configuring PHP Runtime Environment, fastcginginx_php tutorial

Source: Internet
Author: User
Tags configuration php

Php+fastcgi+nginx Configure PHP Runtime environment, Fastcginginx


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.                   }


For PHP, Nginx, FastCGI

Nginx provides Web services similar to Apache, IIS, and lighthttp;
If the Web service receives a PHP file request, it forwards the request to PHP processing and returns the processing result;
FastCGI is a mode of operation for PHP and can be run in CGI or ISAPI mode.
In addition, if you are using the Windows platform, it is recommended to use Apache+php+mysql, simple, if it is not to be related to Microsoft's IIS, may be more troublesome, at least I think; if you use the Linux platform, it is recommended to use Nginx+php+mysql, PHP5.3 has built-in PHP-FPM, easy to install and use.
Windows platform can also use Nginx, need to contact again, is being used, ready-made. I'm using Linux+nginx+php+mysql+postgresql+mongodb now.

This period of time to look at the use of Apache or Nginx with fastcgi to run PHP data, the data said, "After fastcgi, PHP interpretation program

No need to restart the server, I developed the settings is on the win2003+apache+php+fastcgi, there is no delay in effect of the situation. It is also important to note that loading memory is not the PHP file itself, but the interpreter, PHP interpreter every time the release will consume system resources, the original multi-process into a lightweight process to remove the frequent interpreter loading and unloading, reducing the system pressure, which is not in conflict with PHP file updates.

http://www.bkjia.com/PHPjc/860469.html www.bkjia.com true http://www.bkjia.com/PHPjc/860469.html techarticle Php+fastcgi+nginx Configuration PHP Runtime Environment, Fastcginginx CGI English is all called Common Gateway Interface (Public Gateway Interface), is nginx and dynamic script program bridge, Nginx through FASTCG ...

  • 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.