PHP + FastCGI + Nginx configure the PHP runtime environment. fastcginginx_PHP tutorial

Source: Internet
Author: User
PHP + FastCGI + Nginx configure the PHP runtime environment, fastcgingruntime. PHP + FastCGI + Nginx configure the PHP runtime environment. fastcginginxCGI is called CommonGatewayInterface (public Gateway Interface) in English and serves as a bridge between Nginx and dynamic scripting programs, nginx uses FastCG PHP + FastCGI + Nginx to configure the PHP runtime environment, fastcgingruntime

CGI is called the Common Gateway Interface (public Gateway Interface) in English and serves as a bridge between Nginx and dynamic scripting programs. Nginx sends dynamic requests to FastCGI through the FastCGI Interface, the Wrapper process in FastCGI generates a thread and sends the request to the script interpreter for execution. then, the original result is returned to Nginx through the original socket, and then Nginx delivers the result to the client.

Nginx uses the socket file socket to send dynamic requests to wrapper, using the Tcp protocol. Wrapper uses the CGI interface to accept requests. In this way, the web server and the interpreter can be developed independently, which avoids errors, crashes, and security problems caused by the interpreter directly calling the server interface. In addition, Nginx can focus on static page requests and forward dynamic requests, and install the script interpreter on another server, so that the pressure on the server can be apportioned.

CGI is developed as a patch for PHP programs. to install PHP, first install the library on which it depends, then, you can add options such as enable-fpm-enable-CGI when compiling configuration parameters. To compile the PHP extension module, you need to use the phpize tool in php to generate the configure file during Module compilation. if you cannot generate the configure file when running phpize, the reason is: The autoconf package is not installed.

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

Nginx configuration supports fastcgi:

Location ~ \. Php $ {root html; fastcgi_pass unix:/tmp/fastcgi. soke // establish a connection with cgi through the socket file, which sets fastcgi_index index in the php-fpm.conf. php; fastcgi_param SCRIPT_FILENAME html $ SCRIPT_FILE_NAME; set the parameter include fastcgi_params; // import the fastcgi parameter configuration file, which is automatically generated during nginx installation. }


For PHP, Nginx, FastCGI

Nginx provides web services, such as Apache, IIS, and lighthttp;
If the web service receives a php file request, it transfers the request to php for processing and returns the processing result;
FastCGI is a php running mode. In addition, it can run in CGI or ISAPI mode.
In addition, if you are using a windows platform, it is recommended to use Apache + PHP + Mysql. it is simpler. if you have to link it with Microsoft's IIS, it may be troublesome, at least I think so; if you are using the Linux platform, we recommend that you use Nginx + PHP + Mysql and PHP5.3 with built-in php-fpm, which is easy to install and use.
You can also use Nginx on the Windows platform. if you need it, contact us again. it is in use and ready for use. I now use Linux + Nginx + PHP + Mysql + Postgresql + Mongodb.

During this time, I read the information about using Apache or Nginx with fastcgi to run php. the document says, "after fastcgi is used, PHP interpreter

You do not need to restart the server. I developed the settings on win2003 + apache + php + fastcgi, without any delay. Note that loading the memory is not a php file, but an interpreter. The php interpreter consumes system resources every time it is enabled and released, the original multi-process becomes a lightweight process, removing frequent interpreter loading and uninstalling, reducing the system pressure, which is not in conflict with PHP file updates.
 

The Common Gateway Interface (public Gateway Interface) is a bridge between Nginx and dynamic scripting programs. Nginx uses FastCG...

Related Article

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.