首先獲取并解壓PHP安裝包
[root@localhost src]# cd /usr/local/src/
[root@localhost src]# wget http://cn2.php.net/get/php-7.1.3.tar.gz/from/this/mirror
[root@localhost src]# tar zxvf mirror
安裝工具和相應擴展
[root@localhost src]# yum install gcc gcc++ libxml2-devel curl-devel libjpeg-devel libpng-devel libc-client-devel freetype-devel unixODBC-devel libicu-devel libxslt-devel libmcrypt-devel
[root@localhost src]# yum install glibc-headers
[root@localhost src]# yum install gcc-c++
開始編譯PHP
./configure的作用是檢測系統配置,生成makefile文件,以便你可以用make和make install來編譯和安裝程序
[root@localhost src]# cd php-7.1.3
[root@localhost php-7.1.3]# ./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-config-file-scan-dir=/usr/local/php7/etc/php.d --with-fpm-user=www --with-fpm-group=www --enable-fpm --disable-fileinfo --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif --enable-sysvsem --with-curl --enable-mbregex --enable-inline-optimization --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
如果出現缺失SSL,如下:
[root@localhost php-7.1.3]# yum install openssl-devel
沒出現錯誤就可以開始編譯了
[root@localhost php-7.1.3]#? make &&make install
測試
root@localhost php-7.1.3]# cd ~
[root@localhost ~]# vi phpinfo.php
<?php
echo phpinfo();
運行腳本
[root@localhost ~]# /usr/local/php7/bin/php phpinfo.php
出現下圖就成功了