Centos7 编译安装PHP7.4

首先安装依赖包:

yum -y install gcc gcc-c++ openssl openssl-devel libxml2 libxml2-devel curl-devel libjpeg-devel bzip2-devel.x86_64 libXpm-devel gmp-devel icu libicu libicu-devel php-mcrypt libmcrypt libmcrypt-devel postgresql-devel libxslt-devel libpng-devel libpng freetype-devel

安装libzip:

wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar xf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install

下载源码文件:

wget https://www.php.net/distributions/php-7.4.0.tar.gz
tar xf php-7.4.0.tar.gz
cd php-7.4.0

预编译:

./configure –prefix=/usr/local/php –enable-opcache –with-config-file-path=/usr/local/php/etc –with-curl –enable-fpm –enable-gd –with-iconv –enable-mbstring –with-mysqli=mysqlnd –with-openssl –enable-static –enable-sockets –enable-inline-optimization –with-zlib –disable-ipv6 –disable-fileinfo –disable-debug

如提示“No package ‘oniguruma’ found”需要安装 oniguruma包(可以参考 https://github.com/kkos/oniguruma#install):

yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-5.9.5-3.el7.x86_64.rpm
yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-5.9.5-3.el7.x86_64.rpm

如提示“No package ‘sqlite3’ found:

wget -P /data/tmp https://sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
cd /data/tmp/ && tar xf sqlite-autoconf-3280000.tar.gz
cd sqlite-autoconf-3280000
./configure
make && make install
whereis sqlite3
mv /usr/bin/{sqlite3,sqlite3.7}
cp /usr/local/bin/sqlite3 /usr/bin/sqlite3
sqlite3 –version
export LD_LIBRARY_PATH=”/usr/local/lib”
yum install sqlite-devel

然后执行make && make install 开始编译

分享到:

评论已关闭。