My web server was running PHP version 5.3 for a long time and now I would like to en-cash the advantages of PHP 7.0. So I decided to upgrade PHP 5.3 to PHP 7.0. As this is a production web server, I don’t want to disturb the existing setup and also, I don’t want to have multiple versions on PHP installed. So it should be a pure upgrade of PHP.
Here is a quick guide to help you upgrade default PHP provided on Fedora, CentOS, RHEL to latest version 7.0 (at the time of writing this article).
Step 1: How to configure Remi repository in CentOS/Fedora/RHEL
RHEL 6.7
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
RHEL 7.2
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
Centos 6.7
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
CentOS 7.2
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
Fedora 23
wget http://rpms.remirepo.net/fedora/remi-release-23.rpm dnf install remi-release-23.rpm
Step 2: Activate Remi repository
By default, Remi-safe repository would be enabled and remi-php70 would be disabled. If you want to enable it permanently, open the file /etc/yum.repos.d/remi.repo and change the value of enabled from 0 to 1 under remi-php70 section.
vim /etc/yum.repos.d/remi.repo
or by using the below yum command:
RHEL et CentOS
yum-config-manager --enable remi-php70
Fedora
dnf config-manager --set-enabled remi-php70
Step 3: Upgrade PHP 5.3 to PHP 7.0
yum update
That’s all 🙂
Step 4: Verify the PHP version
You may verify PHP version using the below command:
php --version PHP 7.0.24 (cli) (built: Sep 26 2017 18:04:56) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
Thanks, it worked for me.