Check the Lib libraries required to install PHP
Yum Install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-develyum Install freetype-devel libpng-devel gd libcurl-devel libxslt-develyuminstall OpenSSL Openssl-devel #PHP所需的依赖包
Install the Libiconv library that Yum cannot install #以下4个包可以下载后打包为rpm包以供下次使用
Yum Install wget wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gztar XF libiconv- 1.14. tar. gz-c/usr/src//usr/src/libiconv-1.14/. Make Make Install
Install Libmcrypt library mhash encryption Extension Library MCRVPT encryption Extension Library
Install with the Epel yum source
Yum Install mhash mcrypt libmcrypt-devel
Unzip the PHP source package
tar XF php-5.3. . tar. gz-c/usr/src//usr/src/php-5.3. /
Compile
./configure--PREFIX=/USR/LOCAL/PHP5.3.28--with-mysql=/usr/local/mysql--with-iconv-dir=/usr/local/libiconv--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/USR--enable-xml--disable-rpath--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem-- Enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring-- With-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets-- With-xmlrpc--enable-Zip--enable-soap--enable- Short-tags--enable-zend-multibyte--enable-static--with-xsl--with-fpm-user=www--with-fpm-group=www--enable-FTP
After compilation, this display indicates successful compilation
#部分参数解释
:--prefix=/usr/local/php5.2.28
Indicates that the installation path for the specified PHP is/usr/local/php5.3.28
:--with-mysql=/usr/local/mysql
Indicates that you need to specify the installation path for MySQL and install the MySQL-related content required by PHP. Of course, if you don't have a MySQL package, you can not install it individually, so you can use--WITH-MYSQL=MYSQLND instead of--with-mysql=/usr/local/mysql. Because the PHP software has its own client-side tool to connect to MySQL.
:--with-fpm-user=www
Nginx indicates that the user named PHP-FPM process Management is WWW, and it is best to unify with Nginx service users.
:--with-fpm-group=www
Indicates that the group specified for the PHP-FPM process management is WWW, which is best to unify with the Nginx service user group.
:--ENABLE-FPM
Indicates the activation of the PHP-FPM mode service, that is, running the PHP service in fastcgif mode.
After the correct implementation of the previous configuration of the PHP software./configure Series command, you can compile the PHP software, the specific operation process is as follows:
Ln -s/usr/local/mysql/lib/libmysqlclient.so. - Ln -s/usr/local/mysql/lib/libmysqlclient.so. /usr/lib64/touch ext/phar/phar.pharmake#make最后的正确提示Build Complete. Don' make Test'. Make Install
Configuration file
LN-s/usr/local/php5.3.28//usr/local/php #拷贝PHP配置文件到PHP默认目录, and changing the file name is called PHP. inchCD/usr/src/php-5.3. -/CPphp.ini-production/usr/local/php/lib/php.ini #配置PHP (fastcgi mode) configuration file php - fpm.confcd/usr/local/php/etc/CPPhp-fpm.conf.default php-Fpm.conf
#启动PHP服务php -fpm, the command is as follows/usr/local/php/sbin/php-FPMPS-ef |grepphp-Fpmroot126611 1 0 -: $?xx:xx:xxPhp-fpm:master process (/USR/LOCAL/PHP5.3.28/etc/php-fpm.conf) Nginx126612 126611 0 -: $?xx:xx:xxphp-Fpm:pool www nginx126613 126611 0 -: $?xx:xx:xxphp-Fpm:pool www root126619 126548 0 -: thepts/1 xx:xx:xx grepphp-fpm
Configuration nginx Support PHP program request access
Modify/usr/local/nginx/conf/www.conf Virtual User profile server {Listen under extra the; server_name www.wk.com; Location/{root/var/www/html/wwwcom; Index index.html index.htm; } error_page - 502 503 504/50x.html; Location= /50x.html {root/var/www/html; } Location~.*\. (PHP|PHP5)?$ { #新增支持php root /var/www/html/wwwcom; Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Include fastcgi.conf; }}nginx-T #检测语法nginx-S Reload#重新启动
Test LNMP
cd/var/www/html/wwwcom/echo"<?php phpinfo ();?>" >test_info.php
Client Web service: I service side P address/test_info.php
for Nginx Request Access PHP , and then to PHP Connection MySQL to test the situation
Vim test_mysql.php<?PHP//$link _id=mysql_connect (' Host name ', ' user ', ' password ');$link _id=mysql_connect ('localhost','Root','123456');if($link _id) {Echo "MySQL successful by mr.wang!";}Else{Echomysql_error ();}?>
PHP installation (combined with the previous Nginx installation and MySQL installation as LNMP)