安装依赖
yum -y install gcc gcc-c++ autoconf automake bison cmake curl curl-devel libzip libXpm libcurl-devel zlib-devel libcom_err-devel libpng-devel libjpeg* libsepol-devel libselinux-devel openssl openssl-devel pcre-devel php-common php-gd wget zlib ncurses-devel libxml2 libxml2-devel gd-devel flex bzip2 libmcrypt yasm nasm readline-devel libvpx-devel t1lib*
安装libmcrypt(php扩展)
wget -c https://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install
编译安装PHP 5.6.31
wget -c http://mirrors.sohu.com/php/php-5.6.31.tar.gz
tar -zxvf php-5.6.31.tar.gz
cd php-5.6.31
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local /php/etc \
--with-mysql=mysqlnd --with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-png-dir=/usr \
--with-jpeg-dir=/usr \
--with-freetype-dir=/usr \
--with-vpx-dir=/usr \
--with-t1lib=/usr \
--with-libxml-dir=/usr/include /libxml2/libxml \
--with-openssl-dir=/usr \
--with-openssl \
--without-pear \
--with-gettext \
--with-readline \
--with-mhash \
--with-mcrypt \
--with-xmlrpc \
--with-iconv \
--with-curl \
--with-zlib \
--with-bz2 \
--with-gd \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-session \
--enable-sockets \
--enable-sysvsem \
--enable-sysvmsg \
--enable-sysvshm \
--enable-opcache \
--enable-mbregex \
--enable-libxml \
--enable-bcmath \
--enable-shmop \
--enable-pcntl \
--enable-ctype \
--enable-soap \
--enable-fpm \
--enable-ftp \
--enable-zip \
--enable-cli \
--enable-xml
make
make install
文件配置
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
ln -sb /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
编辑配置文件
vi /etc/php-fpm.conf
pid = run/php-fpm.pid #取消前面的分号
vi /etc/php.ini
date .timezone = Asia/Shanghai
expose_php = Off #禁止显示php版本的信息
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/"
测试php-fpm配置
/usr/local/php/sbin/php-fpm -t
[26 -Aug-2017 10 :28 :37 ] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful
ln -sb /usr/local/php/bin/php /usr/bin/
php -v
PHP 5.6 .31 (cli ) (built : Aug 26 2017 10:00 :00)
Copyright (c ) 1997-2016 The PHP Group
Zend Engine v2 .6 .0 , Copyright (c ) 1998-2016 Zend Technologies
设置 php-fpm开机启动
cp /root/php-5.6.3/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod 755 /etc/rc.d/init.d/php-fpm
chkconfig php-fpm on