在CentOS系统中升级PHP-FPM版本,可以按照以下步骤进行操作:
安装Remi仓库
sudo yum install epel-release
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
启用Remi仓库
sudo yum-config-manager --enable remi-php74 # 替换为你需要的PHP版本,例如php73, php74, php80等
更新PHP-FPM
sudo yum update php-fpm
重启PHP-FPM服务
sudo systemctl restart php-fpm
如果你需要安装特定版本的PHP-FPM,或者Remi仓库中没有你需要的版本,可以手动编译安装:
安装依赖包
sudo yum install -y gcc make autoconf libc-dev zlib-devel libxml2-devel bzip2 bzip2-devel curl curl-devel libjpeg-devel libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel mhash mhash-devel openssl openssl-devel
下载PHP源码
wget https://www.php.net/distributions/php-7.4.33.tar.gz # 替换为你需要的PHP版本
tar -zxvf php-7.4.33.tar.gz
cd php-7.4.33
配置和编译
./configure --prefix=/usr/local/php --with-config-file-path=/etc/php-fpm.d --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql --with-zlib --with-curl --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr
make && sudo make install
配置PHP-FPM 将编译安装的PHP-FPM配置文件复制到系统配置目录:
sudo cp sapi/fpm/php-fpm.conf /etc/php-fpm.d/www.conf
sudo cp sapi/fpm/init.d/php-fpm /etc/init.d/php-fpm
启动PHP-FPM服务
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
无论使用哪种方法,都可以通过以下命令验证PHP-FPM是否成功升级:
php-fpm -v
这将显示当前安装的PHP-FPM版本。
通过以上步骤,你应该能够成功升级CentOS系统中的PHP-FPM版本。