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

Hi, in this tutorial we’ll install or upgrade php version to 7.4, currently I’m pretty much impressed with php 7.4 performance out of the box with default values. This blog is running on wordpress + php 7.4 + nginx (I don’t like Apache) and I’ve found 10-15% of performance is increased like loading performance increase, post publishing is now faster and opcache is pretty much improved.

PHP 7.4 comes with a numerous amount of new features. It is recommended to check your script compatibility before upgrading. SO without wasting much time in reading let start with the upgrade steps :

Upgrade to php 7.3 : https://blog.alphagnu.com/how-to-upgrade-php-5-6-to-php-7-3-on-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
[root@server ~]# 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.

Back to top button