Nginx itself can not handle PHP, it is just a Web server, when the request is received, if it is a PHP request, then sent to the PHP interpreter processing, and the results returned to the client.
Nginx is generally the request to send fastcgi management process processing, FASCGI management process Select the CGI subprocess processing results and return to be Nginx
This article takes php-fpm as an example to explain how to make Nginx support PHP
I. Compiling and installing PHP-FPM
What is PHP-FPM
PHP-FPM is a PHP fastcgi manager that is only used in PHP and can be downloaded in http://php-fpm.org/download.
PHP-FPM is actually a patch of PHP source code, designed to integrate FASTCGI process management into the PHP package. It must be patch to your PHP source code and can be used only after compiling and installing PHP.
The new version of PHP has been integrated PHP-FPM, no longer a third party package, recommended use . PHP-FPM provides a better way to manage PHP processes, can effectively control memory and process, can smooth overload PHP configuration, more than spawn-fcgi have a bit more, so the official PHP included. In the./configure with the –ENABLE-FPM parameter can be opened PHP-FPM, the other parameters are configured PHP, the meaning of the specific options can be viewed here.
Prepare before installation
Execute under CentOS
| Install gcc automake autoconf libtool make yum-y install gcc gcc-c++ glibc yum-y install libmcrypt-devel MHAs yum-y H-devel libxslt-devel \ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \ zlib Zli B-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs e2fsprogs -devel \ krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel |
New PHP-FPM installation (recommended installation method)
| wget http://cn2. php.net/distributions/php-5.4.7. Tar. GZ tar zvxf php-5.4.7. Tar. gz CD php-5.4.7. /configure--prefix=/usr/local/php --enable-fpm--with-mcrypt, enable-mbstring--disable-pdo,--with-curl isable-debug --disable-rpath \--Enable-inline-optimization--with-bz2 --with-zlib--enable-sockets \--E Nable-sysvsem--ENABLE-SYSVSHM--enable |