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
php编译配置文件中指定了apache和mysql的路径,所以说需要先安装apache和mysql,初次安装会缺少各种库文件
yum list | grep xml2
yum install -y libxml2-devel.x86_64
configure: error: Cannot find OpenSSL‘s <evp.h>
yum install -y openssl-devel
基本都是缺少库文件,相同方法就可以解决问题 安装 libxxxx-devel 或者 xxx-devel 即可
yum install -y libxml2-devel.x86_64
yum install -y openssl-devel
yum install -y bzip2-devel
yum install -y libpng-devel
yum install -y freetype-devel
yum install -y epel-release
yum install -y libmcrypt-devel
完成之后(记得echo $? 检查是否成)
make && make install
cp php.ini-production /usr/local/php/etc/php.ini //复制配置文件
/usr/local/php/bin/php -i | less //查看php的配置信息
/usr/local/php/bin/php -m //查看php的扩展,都是静态的
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
tar jxvf 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
cp php.ini-production /usr/local/php7/etc/php.ini
ls /usr/local/apache2.4/modules/ | grep libphp //apache需要的就是这两个扩展文件
vim /usr/local/apache2.4/conf/httpd.conf //查看apache加载了哪些扩展,不需要的直接#注释掉即可
/usr/local/php7/bin/php -i | less //查看php7的配置相关信息
原文地址:http://blog.51cto.com/13569831/2097199