本次安装php8.2使用的是源码包安装方法。该方法可以按照实际需要配置php模块,灵活度较高。
安装过程比较简单,主要是安装php所需要的依赖比较繁琐。下文就比较常见的依赖包安装方法进行了归纳汇总。
#下载php8.3.1软件包
curl -o /root/php-8.3.1.tar.gz https://www.php.net/distributions/php-8.3.1.tar.gz
#解压缩
tar xf php-8.3.1.tar.gz
#配置阿里云yum源
rm -rf /etc/yum.repos.d/*.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum makecache
#安装编译工具
yum -y install gcc make
#进入php源码包目录
cd php-8.3.1
#使用./configure自定义需要的模块,生成Makefile文件
./configure --prefix=/usr/local/php/ --build=x86_64-linux-gnu --with-config-file-path=/usr/local/etc/php --with-config-file-scan-dir=/usr/local/etc/php/conf.d --enable-option-checking=fatal --with-mhash --with-pic --enable-ftp --enable-mbstring --enable-mysqlnd --with-password-argon2 --with-sodium=shared --with-pdo-sqlite=/usr --with-sqlite3=/usr --with-curl --with-iconv --with-openssl --with-readline --with-zlib --disable-phpdbg --with-pear --with-libdir=lib/x86_64-linux-gnu --disable-cgi --enable-fpm --with-fpm-user=www-data
--with-fpm-group=www-data --with-mysqli
#根据提示安装需要的依赖
yum -y install libxml2 libxml2-devel
yum -y install openssl-devel
yum -y install sqlite-devel
yum -y install libcurl-devel
yum -y install readline-devel
#安装依赖oniguruma包
mkdir /root/onigur
cd /root/onigur/
curl -o /root/onigur/oniguruma-devel-6.8.2-2.el8.x86_64.rpm \
http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
curl -o /root/onigur/oniguruma-6.8.2-2.el8.x86_64.rpm \
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/oniguruma-6.8.2-2.el8.x86_64.rpm
yum -y install oniguruma-devel-6.8.2-2.el8.x86_64.rpm
yum -y install oniguruma-6.8.2-2.el8.x86_64.rpm
#安装依赖libsodium包
curl -o /root/last.tar https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
tar -zxf LATEST.tar.gz
cd libsodium-stable/
./configure
make && make install
vim /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
source /etc/profile
pkg-config --list-all | grep libsodium #查看是否安装成功
#安装依赖libargon2
curl -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/libargon2-20171227-3.el8.x86_64.rpm
curl -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/libargon2-devel-20171227-3.el8.x86_64.rpm
yum -y install libargon2-20171227-3.el8.x86_64.rpm libargon2-devel-20171227-3.el8.x86_64.rpm
#安装php
cd /root/php-8.3
make && make install
php ./configure通过后,会出现下图所示提示
make install后会显示如下界面
评论