安装php5

cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxf php-5.6.30.tar.gz
cd php-5.6.30
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

提示
configure: error: xml2-config not found. Please check your libxml2 installation.

php安装

解决方法: yum install -y libxml2-devel

提示:
php安装
解决方法:yum install -y openssl-devel

提示:
configure: error: Please reinstall the BZip2 distribution
解决方法:yum install -y bzip2-devel

提示:configure: error: jpeglib.h not found.
解决方法:yum install -y libjpeg-devel

提示:configure: error: png.h not found.
解决方法:yum install -y libpng-devel

提示:configure: error: freetype-config not found.
解决方法:yum install -y freetype-devel

提示:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方法:
yum install -y epel-release
yum install -y libmcrypt-devel
问题解决

make
make install

拷贝配置文件到目录下
cp php.ini-production /usr/local/php/etc/php.ini

配置php7
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
tar zxf php-7.1.6.tar.bz2
cd php-7.1.6
./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
make && make install
ls /usr/local/apache2.4/modules/libphp7.so
du -sh !$
查看apache加载的php
cp php.ini-production /usr/local/php7/etc/php.ini