How To Install PHP 7.3 On RHEL 8

RHEL 8 comes with PHP v7.2 by default.

PHP is an open-source programming language widely for web development, created by Rasmus Lerdorf. It is an HTML-embedded scripting language for creating dynamic web sites.

RHEL 8 comes with PHP v7.2 by default.

In this post, we will see how to install PHP 7.3 on RHEL 8.

Add Remi Repository on RHEL 8

Remi, a third-party repository which offers multiple versions of PHP (7.4 / 7.3 / 7.2) for Red Hat Enterprise Linux.

Remi repository requires EPEL repository be enabled on your system.

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

To enable the Remi repository on your system, install the Remi repository auto-configuration package using the below command.

yum install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Output:

Last metadata expiration check: 0:00:04 ago on Thu 19 Sep 2019 03:20:07 AM UTC.
remi-release-8.rpm                                                                  14 kB/s |  21 kB     00:01    
Dependencies resolved.
===================================================================================================================
 Package                     Arch                  Version                       Repository                   Size
===================================================================================================================
Installing:
 remi-release                noarch                8.0-3.el8.remi                @commandline                 21 k

Transaction Summary
===================================================================================================================
Install  1 Package

Total size: 21 k
Installed size: 19 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                           1/1 
  Installing       : remi-release-8.0-3.el8.remi.noarch                                                        1/1 
  Verifying        : remi-release-8.0-3.el8.remi.noarch                                                        1/1 

Installed:
  remi-release-8.0-3.el8.remi.noarch                                                                               

Complete!

Install PHP 7.3 on RHEL 8

List the available PHP module stream.

Also Read: Install PHP 7 on CentOS 7 / RHEL 7 & CentOS 6 / RHEL 6

yum module list php

You should see below output.

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name            Stream                  Profiles                                  Summary                          
php             remi-7.2                common [d], devel, minimal                PHP scripting language           
php             remi-7.3                common [d], devel, minimal            PHP scripting language           
php             remi-7.4                common [d], devel, minimal                PHP scripting language           

Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs)
Name            Stream                  Profiles                                  Summary                          
php             7.2                     common [d], devel, minimal                PHP scripting language           

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Enable php:remi-7.3 module to install PHP 7.3.

yum module enable php:remi-7.3 -y

Output:

Last metadata expiration check: 0:00:19 ago on Thu 19 Sep 2019 03:20:56 AM UTC.
Dependencies resolved.
===================================================================================================================
 Package                    Arch                      Version                     Repository                  Size
===================================================================================================================
Enabling module streams:
 httpd                                                2.4                                                         
 nginx                                                1.14                                                        
 php                                                  remi-7.3                                                    

Transaction Summary
===================================================================================================================

Complete!

Switching module streams does not alter installed packages (see 'module enable' in dnf(8) for details)

Install PHP 7.3 on RHEL 8 with yum command.

yum install -y php php-cli php-common

Check PHP Version

Once you have installed PHP, check the PHP version with the following command.

php -v

Output:

PHP 7.3.9 (cli) (built: Aug 27 2019 22:52:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.9, Copyright (c) 1999-2018, by Zend Technologies

Install PHP-FPM

If you are setting up LEMP stack on RHEL 8, you might want to install php-fpm 7.3.

yum install -y php-fpm

Install PHP Extensions

PHP extensions are compiled libraries which enables specific support for your code.
To have MySQL support on your code, you can install php-mysqlnd package.

yum install -y php-mysqlnd

Once you have installed MySQL extension, you can use the below command to verify it.

php -m | grep -i mysql

Output:

mysqli
mysqlnd
pdo_mysql

PHP Extensions for WordPress

The following extensions are required to install and run WordPress on your RHEL 8 machine. WordPress recommends PHP v7.3 for the installation.

yum install -y php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-date php-exif php-filter php-ftp php-gd php-hash php-iconv php-json php-libxml php-pecl-imagick php-mbstring php-mysqlnd php-openssl php-pcre php-posix php-sockets php-spl php-tokenizer php-zlib

PHP Extensions for Joomla

The following extensions are required to install and run Joomla on your RHEL 8 machine. Joomla requires PHP v7.1 and above.

yum install -y php-mysqlnd php-zlib php-xml php-pear php-json php-mcrypt php-pecl-imagick

PHP Extensions for Drupal

The following extensions are required to install and run Joomla on your RHEL 8 machine. Drupal requires PHP v7.1 and above.

yum install -y php-mysqlnd php-date php-dom php-filter php-gd php-hash php-json php-pcre php-pdo php-session php-simplexml php-spl php-tokenizer php-xml

Conclusion

That’s All. I hope you have learned how to install PHP 7.3 on RHEL 8. Please share your feedback in the comments section.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More