一、安装必要的模块
yum install -y bzip2-devel libcurl-devel libxml2-devel sqlite-devel oniguruma oniguruma-devel libxml2 libxml2-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel zstd libzstd-devel curl libcurl-devel libpng libpng-devel
二、安装PHP
1.下载PHP官方包
在https://www.php.net官网中,查看安装包链接,选择上方“download”, Current Stable PHP 8。
wget https://www.php.net/distributions/php-8.1.9.tar.gz
tar -xzxvf php-8.1.9.tar.gz
2.设置编译需要加载的模块
mkdir php-8.1.9-build
cd php-8.1.9-build
../php-8.1.9/configure --prefix=/usr/local/php-8.1.9 --enable-fpm --with-mysqli --enable-mbstring --with-bz2 --with-curl --enable-gd --with-zip --with-zlib --with-openssl
make -j2 # 双核服务器参数配置
make install
cd ..
3.设置环境变量
#设置环境变量
touch /etc/profile.d/php.sh
chmod 777 /etc/profile.d/