How to Install/Upgrade to PHP 7.4 on RHEL/CentOS VestaCP

STEP 1 :

Install Remi Repository and EPEL Repository on your server :

RHEL 8

dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

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 8

dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

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

STEP 2 :

After you have installed repository you need to follow some extra configurations :

Run this command one by one for RHEL 8 or CentOS 8 :

dnf install dnf-utils
dnf module reset php
dnf module enable php:remi-7.4

Run this command one by one for RHEL 6, 7 or CentOS 6, 7 :

yum install yum-utils
yum-config-manager --enable remi-php74

STEP 3 :

Under RHEL 8 and Centos 8

To Install php 7.4:

dnf install php php-opcache php-gd php-curl php-mysqlnd

** you can list all php and install the packages you need.

To upgrade from previous php version to 7.4 :

Now just run this command :

dnf module install php:remi-7.4
dnf update -y

Under RHEL6, 7 and Centos 6, 7

To Install php 7.4:

yum install php php-opcache php-gd php-curl php-mysqlnd

** you can list all php and install the packages you need.

To upgrade from previous php version to 7.4 :

Now just run this command :

yum update -y

You’ll see php packages are getting updated, After the update process you need to restart Apache server/php-fpm-(nginx) and check the php version from by below mentioned command:

php -v
[[email protected] ~]# php -v
PHP 7.4.2 (cli) (built: Jan 21 2020 11:35:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies

Troubleshoot

Under RHEL 8 and Centos 8

you need to run this commands to disable php 5.6/7.0/7.1/7.2/7.3 :

dnf module disable php:remi-5.6
dnf module disable php:remi-7.0
dnf module disable php:remi-7.1
dnf module disable php:remi-7.2
dnf module disable php:remi-7.3

Under RHEL6, 7 and Centos 6, 7

If php upgrade process fails (no update/nothing happens) or you upgraded php previously to 7.0/7.1/7.2/7.3 then you need to run this commands to disable php 5.6/7.0/7.1/7.2/7.3 :

yum-config-manager --disable remi-php56
yum-config-manager --disable remi-php70
yum-config-manager --disable remi-php71
yum-config-manager --disable remi-php72
yum-config-manager --disable remi-php73

After that follow the tutorial from STEP 2 again.