I install the LNMP environment of the relevant files, can be inI provide the Baidu cloud disk resources to downloadLink: http://pan.baidu.com/s/1dD6QZ1B Password: zcs8
I. Overview
PHP full name Php:hypertext preprocessor hypertext processor, open source scripting language!
Its interface with Web server supports three forms, namely CGI, module mode, fastcgi mode. And for Nginx, only support CGI and fastcgi two kinds of interface way to connect with PHP!
This section will install PHP with source code, start the PHP-FPM service (FastCGI interface) and connect with Nginx.
For the configuration of Nginx, please see the previous section of the relevant introduction!
Ii. preparatory work
1. Install Dependent Development Package
# yum install-y libxml2-devel bzip2-devel libcurl-devel libmcrypt-devel
2. Source code Download
Address: http://php.net/downloads.php Download the required version and use php-5.5.27.tar.bz2 here.
You can also use my installation files, already exist Baidu cloud disk---please see the beginning of the article.
Three, installation configuration
1. Configuration
--prefix Specifying the installation directory
--with-mysql=mysql_dir installing the MySQL module specifying its installation path
--with-openssl Installing the OpenSSL module
--ENABLE-FPM supports FPM, for fastcgi mode, this module must be enabled
--enable-sockets support socket, for FASTCGI mode, this module must be turned on
--ENABLE-SYSVSHM supports system V shared memory
--with-mysqli=mysql_config_path Installing the Mysqli module
--with-config-file=config_dir Specifying the PHP configuration file installation path
--WITH-CONFIG-FILE-SCAN-DIR=CONFIG_DIR Specifies the scan path of the configuration file, which is the other profile path except the Master profile php.ini
--WITH-MYSQLND=SHARE,MYSQLND Support MYSQLND
--with-enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib-dir--with-libxml-dir ...
Install some PHP related extensions file
Configured as follows
#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--with-openssl--enable-fpm--enable-sockets-- ENABLE-SYSVSHM--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-mbstring--with-freetype-dir-- With-jpeg-dir--with-png-dir--with-zlib-dir--with-libxml-dir=/usr--enable-xml--with-mhash--with-mcrypt-- With-config-file-path=/etc--with-config-file-scan-dir=/etc/php.d--with-bz2--with-curl--with-mysql=share, Mysqlnd
2. Compile and install
# make
# make Install
3. Prepare the configuration file
# CP Php.ini-production/etc/php.ini
4, boot start php-fpm
Configure the SysV startup script to add to the list of services
# CP SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM
# chmod +X/ETC/RC.D/INIT.D/PHP-FPM
# chkconfig--add php-fpm
# chkconfig PHP on
5. Add PHP-FPM Service configuration script
# cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
6. Start the service
# service PHP-FPM Start
# Ps-ef | grep php-fpm//Can see that the system has started multiple PHP-FPM processes, indicating that the PHP-FPM service has started successfully
Iv. PHP-FPM and Nginx
1. Edit nginx.conf
Server segment configuration modified as follows, add script parsing function for Nginx
Location/{
root HTML;
Index index.html index.htm index.php;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# Proxy_pass http://127.0.0.1;
#}
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/scripts$fastcgi_script_name;
Include Fastcgi_params;
}
2, modify the/etc/nginx/fastcgi_params
Fastcgi_param query_string $query _string;
Fastcgi_param Request_method $request _method;
Fastcgi_param Content_Type $content _type;
Fastcgi_param content_length $content _length;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param script_name $fastcgi _script_name;
Fastcgi_param Request_uri $request _uri;
Fastcgi_param Document_uri $document _uri;
Fastcgi_param document_root $document _root;
... ...
redefine the Fastcgi_param parameter script_filename
3, Nginx restart
# Service Nginx Restart
4. Test access
Add Edit/usr/local/nginx/index.php
<?php
Phpinfo ();
?>
Browser access/HTTP/domain/index.php, such as
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/71/6B/wKioL1XPyOOT8HGrAAJzaCdOrOw042.jpg "title=" Phpinfo.png "alt=" Wkiol1xpyoot8hgraajzacdorow042.jpg "/>
integrated above, complete the installation of PHP, enable PHP-FPM server and integration with Nginx, testing completed!
LNMP Environment Installation (3)-php source code compilation and installation