PHP is one of the most used server-side programming languages. Many popular CMS and frameworks such as WordPress, Magento, and Laravel are built in PHP.
In this guide, we will discuss how to install PHP 7.4 on CentOS 8. Before choosing which version of PHP to install, make sure that your applications support it.
01- PHP 7.2 is available for installation from the default CentOS 8 repositories. To install PHP 7.4, so we need to enable the Remi repository as below:
$ sudo dnf install epel-release -y $ sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
02- Once the installation is complete, run the below command to get a list of all available PHP versions:
$ dnf module list php
Remi's Modular repository for Enterprise Linux 8 - x86_64 872 kB/s | 565 kB 00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 1.6 MB/s | 1.5 MB 00:00
CentOS-8 - AppStream
Name Stream Profiles Summary
php 7.2 [d] common [d], devel, minimal PHP scripting language
php 7.3 common, devel, minimal PHP scripting language
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
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
03- Let’s now enable remi-7.4 PHP module by running the following command:
$ sudo dnf module enable php:remi-7.4
04- The following command will install PHP and some of the most common PHP modules:
$ sudo dnf install php php-cli php-common
sudo systemctl enable --now php-fpm
.
05- Finally, once the installation is complete, run the below command to get the PHP version:
$ php -v
PHP 7.4.5 (cli) (built: Apr 14 2020 12:54:33) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies
Conclusion
You have successfully installed PHP 7.4 on CentOS 8 by enabling Remi repository. You might want to check the following guides: