CentOS 安装或升级到 PHP 7

本页内容

CentOS 官方仓库的 PHP 版本是 5.4,但此版本已经不再被官方支持,考虑到安全问题和更好的性能,我们有必要安装或升级更高版本的 PHP,比如最新的 7.2。

那么我们进入正文,首先我们需要安装 EPEL 和 Remi,至于这两个是什么,有兴趣的童鞋可以在相关链接进行查阅。

仓库

安装 EPEL

1# yum install epel-release

安装 Remi

1# yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

启用 PHP 仓库

1# yum-config-manager --enable remi-php72

你也可以选择其他版本,如:remi-php56remi-php70remi-php71

如果 yum-config-manager 命令不存在,你需要安装 yum-utilsyum -y install yum-utils

安装或升级

安装 PHP

1# yum install php

升级 PHP

1# yum update

相关链接