本文将以centos 6,7为例, 介绍如何将php5.6升级到php7.3
为什么要升级到php 7.3 因为7.3版本有更好的安全性以及性能提升,并且php7.3比之前任何版本至少快5%
1.在您的服务器上安装Remi Repository和EPEL Repository:
RHEL 7
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
subscription-manager repos --enable=rhel-7-server-optional-rpms
RHEL 6
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
rhn-channel --add --channel=rhel-$(uname -i)-server-optional-6
CentOS 7
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
CentOS 6
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
2.对于RHEL或CentOS逐一运行此命令
yum install yum-utils
yum-config-manager --enable remi-php73
3.更新YUM
yum update -y
您会看到php软件包正在更新,在更新过程之后,您需要重新启动Apache服务器/ php-fpm-(nginx)并通过下面提到的命令检查php版本
php -v
[root@server ~]# php -v
PHP 7.3.0 (cli) (built: Dec 4 2018 16:12:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.0, Copyright (c) 1999-2018, by Zend Technologies
疑难排解
如果php升级过程失败(没有更新/或者什么都没有发生),或者您以前从5.6升级到7.0 / 7.1 / 7.2,则需要运行以下命令以禁用php 5.6 / 7.0 / 7.1 / 7.2:
yum-config-manager-禁用remi-php56
yum-config-manager-禁用remi-php70
yum-config-manager --disable remi-php71
yum-config-manager --disable remi-php72
之后,再次按照步骤2的指南进行操作。
如你喜欢以上内容,可以关注微信公众号:Robert的书签