centos更新php版本的linux命令
时间: 2023-09-23 14:12:14 浏览: 95
在 CentOS 中更新 PHP 版本的命令可以分为两种情况:
1. 通过 Yum 更新 PHP 版本
CentOS 通过 yum 更新 PHP 版本是比较常见的方式,以下是更新至 PHP 7.4 的命令:
```
sudo yum install epel-release
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php74
sudo yum update
sudo yum install php
```
2. 通过编译源码安装 PHP
如果你想要安装的 PHP 版本不在 CentOS 的 Yum 仓库中可以选择通过编译源码的方式安装,以下是通过编译源码安装 PHP 的命令:
```
sudo yum install epel-release
sudo yum group install "Development Tools"
sudo yum install libxml2-devel openssl-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel libmcrypt-devel readline-devel libxslt-devel
wget https://www.php.net/distributions/php-7.4.24.tar.bz2
tar -xf php-7.4.24.tar.bz2
cd php-7.4.24
./configure --prefix=/usr/local/php-7.4.24 --with-config-file-path=/usr/local/php-7.4.24/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysqli --with-pdo-mysql --with-zlib --with-curl --with-gd --with-jpeg --with-png --with-openssl --with-readline --with-libxml --with-xsl --with-bz2 --with-gettext --with-pear --with-zip --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-opcache --enable-zip
make
sudo make install
```
以上两种方式都可以更新 PHP 版本,具体选择哪种方式根据自己的需求进行选择。