一. 首先需要去php官网 https://www.php.net/downloads 下载php源码包 .
# wget https://www.php.net/distributions/php-7.2.31.tar.gz
// 解压安装包
# tar -zxvf php-7.2.31.tar.gz
// 切换至php-7.2.31
# cd php-7.2.31
// 开始编译安装:
#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-jpeg-dir --with-freetype-dir --enable-fpm
编译报错解决:(多为php依赖库可直接进行yum源安装)
1.configure: error: jpeglib.h not found.
解决:yum -y install libjpeg-devel .
2.configure: error: png.h not found.
解决:#yum install libpng
# yum install libpng-devel
3.configure: error: freetype-config not found.
解决:# yum install freetype-devel
4.error: libxml2 not found. Please check your libxml2 installation.
解决:yum install libxml2-devel -y
备注:解决完成,重新执行上面编译命令并且进行
# make && make install.
至此,php7版本安装完成.
测试:可创建一个php文件 vi test.php 执行test.php文件进行检测.
以上为个人亲自安装过程,如果不同见解,请留言交流.