CentOS7源碼安裝php7.3

一、前期準(zhǔn)備

1、更新yum

yum -y update

2、安裝依賴

yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libzip gcc-c++

3、安裝cmake

// 下載安裝包至 /usr/local/src 目錄下
wget https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz -P /usr/local/src
// 解壓并進(jìn)入解壓后目錄
cd /usr/local/src
tar -zxvf cmake-3.14.3.tar.gz
cd cmake-3.14.3
// 安裝(需要一小段時(shí)間,耐心等待)
./bootstrap
make
make install

4、卸載舊版libzip,安裝新版libzip

此操作可解決php7.3編譯錯(cuò)誤 configure: error: Please reinstall the libzip distribution

// 卸載舊版libzip
yum -y remove libzip
// 下載新版libzip至 /usr/local/src 目錄下
wget https://libzip.org/download/libzip-1.5.2.tar.gz -P /usr/local/src
// 解壓并進(jìn)入解壓后目錄
cd /usr/local/src
tar -zxvf libzip-1.5.2.tar.gz
cd libzip-1.5.2
// 創(chuàng)建 build 文件夾并進(jìn)入
mkdir build
cd build
// cmake .. (注意cmake命令后的兩個(gè)英文點(diǎn))
cmake ..
make
make install

5、動(dòng)態(tài)函數(shù)庫(kù)加載的配置新版 lib

此操作可解決php7.3編譯錯(cuò)誤 error: off_t undefined; check your library configuration

vi /etc/ld.so.conf
// 添加下面幾行,如圖 5-1
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
5-1
// 更新配置
ldconfig -v

2、下載安裝php7.3

1、下載安裝php7.3

// 下載php7.3至 /usr/local/src
wget https://www.php.net/distributions/php-7.3.9.tar.gz -P /usr/local/src
// 解壓并進(jìn)入文件夾
cd /usr/local/src
tar -zxvf php-7.3.9.tar.gz
cd php-7.3.9
// 編譯
./configure \
 --prefix=/usr/local/php\
 --enable-fpm\
 --with-fpm-user=www\
 --with-fpm-group=www\
 --with-config-file-path=/usr/local/php/conf\
 --disable-rpath\
 --enable-soap\
 --with-libxml-dir\
 --with-xmlrpc\
 --with-openssl\
 --with-mhash\
 --with-pcre-regex\
 --with-zlib\
 --enable-bcmath\
 --with-bz2\
 --enable-calendar\
 --with-curl\
 --enable-exif\
 --with-pcre-dir\
 --enable-ftp\
 --with-gd\
 --with-openssl-dir\
 --with-jpeg-dir\
 --with-png-dir\
 --with-zlib-dir\
 --with-freetype-dir\
 --enable-gd-jis-conv\
 --with-gettext\
 --with-gmp\
 --with-mhash\
 --enable-mbstring\
 --with-onig\
 --with-mysqli=mysqlnd\
 --with-pdo-mysql=mysqlnd\
 --with-zlib-dir\
 --with-readline\
 --enable-shmop\
 --enable-sockets\
 --enable-sysvmsg\
 --enable-sysvsem \
 --enable-sysvshm \
 --enable-wddx\
 --with-libxml-dir\
 --with-xsl\
 --enable-zip\
 --with-pear
// 安裝
make
make install

2、復(fù)制生成配置文件

cp /usr/local/src/php-7.3.9/php.ini-production /usr/local/php/conf/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

3、編輯 /etc/profile 文件,配置環(huán)境變量

// 編輯配置文件
vi /etc/profile
// 添加下面內(nèi)容
php=/usr/local/php/bin
PATH=$PATH:$php
export PATH
2-1
// 保存并退出編輯后,執(zhí)行 srource /etc/profile 使配置文件生效
source /etc/profile
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容