一. 首先需要去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文件進行檢測.
以上為個人親自安裝過程,如果不同見解,請留言交流.
