Install PHP 7.4 on CentOS 8

|
Last Updated:
|
|

Follow through this guide to install PHP 7.4 on CentOS 8. PHP 7.4 is a minor release of PHP 7 that that comes with a lot of changes meant to boost performance and improve code readability or maintainability. You can check the release changelog.

The official release of PHP 7.4 is set to be on November 28, 2019. It is however available for testing purposes and are not suitable for production use.

Installing PHP 7.4 on CentOS 8

Install PHP REMI Repository

PHP 7.4 is available in remi repository. Therefore, install the remi repository to enable you install PHP 7.4.

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

This command will install both REMI and EPEL repositories.

...
Dependencies resolved.
=======================================================================================================================================================
 Package                              Arch                           Version                                Repository                            Size
=======================================================================================================================================================
Installing:
 remi-release                         noarch                         8.0-4.el8.remi                         @commandline                          20 k
Installing dependencies:
 epel-release                         noarch                         8-5.el8                                extras                                22 k

Transaction Summary
=======================================================================================================================================================
Install  2 Packages
...

Run system update

dnf update

Installing PHP 7.4 on CentOS 8

Once you have the REMI repos in place, you can verify if they provide PHP 7.4 packages.

dnf whatprovides php74
php74-1.0-1.el8.remi.x86_64 : Package that installs PHP 7.4
Repo        : remi-safe
Matched from:
Provide    : php74 = 1.0-1.el8.remi

As you can see from the output above, remi-safe repository provides php 7.4. If all is good, proceed to install PHP 7.4.

If you want to install the PHP 7.4 and replace the default versions of PHP, simply execute the commands below;

dnf module disable php
dnf module install php:remi-7.4

Verify PHP Versions

To check the PHP version installed, simply run the command;

php -v
PHP 7.4.0RC3 (cli) (built: Oct  1 2019 08:30:29) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies

You can as well install the SCL version of PHP. The SCL version is recommended for testing purposes since to easily install and use PHP 7.4 parallel installation to other versions of PHP.

dnf install php74

You can as well verify PHP from Apache web server.

vim /var/www/html/test.php
<?php
 phpinfo();
?>

Save the file and try to access it from browser using the address http://server-IP/test.php.

Install PHP 7.4 on CentOS 8

Installing PHP Extensions

To install other PHP 7.4 modules, simply run;

dnf install php-module_name

Where module_name is the name of the PHP extension. For example, to install MySQL Native Driver module for PHP 7.4;

dnf install php-mysqlnd
Dependencies resolved.
=======================================================================================================================================================
 Package                           Arch                         Version                                       Repository                          Size
=======================================================================================================================================================
Installing:
 php-mysqlnd                       x86_64                       7.4.0~RC3-5.el8.remi                          remi-modular                       253 k
Installing dependencies:
 php-pdo                           x86_64                       7.4.0~RC3-5.el8.remi                          remi-modular                       139 k

Transaction Summary
=======================================================================================================================================================
Install  2 Packages

Total download size: 392 k
Installed size: 1.3 M
Is this ok [y/N]: y

You can list compiled PHP modules by running the command below;

php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
...

That is all on installing PHP 7.4 on CentOS 8. You can now run your tests. Enjoy.

Reference

Remi’s RPM repository – Blog

Related Tutorials

Install PHP 7.4 on Debian 10/Debian 9

Install phpMyAdmin with Nginx on Debian 10 Buster

Install PHP 7.3.4 on Fedora 30

Installing PHP 7.3.3 on CentOS 7.6

How to Install PHP 7.3.3 on Ubuntu 18.04

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

2 thoughts on “Install PHP 7.4 on CentOS 8”

  1. How is CentOS compared to other Linux flavors like Debian for PHP? I am using a provider that is using Debian as its OS (https://www.cloudways.com/en/ ). The performance and stability is great. The patches are on time and there are no security flaws either.

    Reply

Leave a Comment