首先获取并解压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
出现下图就成功了