安装php7

下载与解压

cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
tar jxvf php-7.1.6.tar.bz2

安装php

cd /usr/local/src/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-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

编译与编译安装

make && make install

设置配置文件

cp /usr/local/src/php-7.1.6/php.ini-production /usr/local/php7/etc/php.ini

两版本PHP冲突处理

如果安装了php5后又安装了php7,那么调用Apache调用只能用其中一个;
那么就需要修改配置文件
vim /usr/local/apache2.4/conf/httpd.conf
不想要php5就注释掉LoadModule php5_module modules/libphp5.so
不想要php7就注释掉LoadModule php7_module modules/libphp7.so

查询Apache加载的模块

/usr/local/apache2.4/bin/apachectl -M