How To Install PHP 7.4, 7.3, 7.2, 7.1 on CentOS/RHEL 8
The PHP Version 7.4.0 has been released on November 28, 2019. PHP 7.4 comes with a remarkable amount of new features. This version is RPM are available in the remi-php74 repository and we are using Remi and EPEL yum repositories for installing required packages. You can also check more features in the PHP official site.
Useful Articles:
- HOW TO DOWNGRADE PHP 7.1 TO 5.6 ON UBUNTU
- HOW TO INSTALL PHP 7.4, 7.3, 7.2 & 7.1 ON UBUNTU 19.10
- How To Install PHP 7.4, 7.3, 7.2, 7.1 on CentOS/RHEL 7/6
- HOW TO UPGRADE PHP 5.6 TO 7.1 ON UBUNTU
- MongoDB PHP MODULE (EXTENSION) ON CENTOS 5/6/7
- INSTALL PHP 7 ON CENTOS/RHEL 5/6/7
- HOW TO INSTALL PHP COMPOSER IN CENTOS/RHEL
- HOW TO UPGRADE PHP VERSION 5.4 TO 5.5 ON CENTOS/RHEL 5/6/7
- HOW TO UPGRADE PHP VERSION 5.4 TO 5.6 ON CENTOS/RHEL 6/7
- AGO FUNCTION IN PHP
- PHP MAIL FUNCTION
In this article we will help you to install PHP 7.4, 7.3, 7.2, 7.1 on CentOS/RHEL 8.
Configure Yum Repository
First, you need to install Remi and EPEL yum repositories on your system. Use the following command to install EPEL and Remi repository in your system.
# yum install epel-release
Use the following command based on your system
# rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-8.rpm
Enable and Disable the Module
To install specific version of the PHP you need to enable the module stream.
## Install PHP 7.4 ##
# dnf module install php:remi-7.4
## Install PHP 7.3 ##
# dnf module install php:remi-7.3
## Install PHP 7.2 ##
# dnf module install php:remi-7.2
## Install PHP 7.1 ##
# dnf module install php:remi-7.1
If you want to enable any other version of PHP then before that you need to disable the existing PHP module.
## Install PHP 7.4 ##
# dnf module reset php:remi-7.4
## Install PHP 7.3 ##
# dnf module reset php:remi-7.3
## Install PHP 7.2 ##
# dnf module reset php:remi-7.2
## Install PHP 7.1 ##
# dnf module reset php:remi-7.1
Configure Yum Repository:
Install PHP 7
Now, your system is ready for the PHP 7 installation. Use one of the following commands to install PHP on your system based on your requirements.
# dnf install php
I have installed PHP 7.4 on my system. Now you can run the following command to check PHP version on my system.
# 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
Install PHP Modules
You may also need to install additional PHP modules based on your application requirements. Below command will install some more useful PHP modules.
# dnf install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
To view enabled modules, run:
# php --modules
You can run the following command to search other available PHP modules under configured yum repositories. Below example command search for all modules for PHP 7.3.
# dnf search php | grep php74
php74.x86_64 : Package that installs PHP 7.4 php74-php-lz4.x86_64 : LZ4 Extension for PHP php74-php-pecl-csv.x86_64 : CSV PHP extension php74-php-pecl-hprose.x86_64 : Hprose for PHP php74-php-common.x86_64 : Common files for PHP php74-unit-php.x86_64 : PHP module for NGINX Unit php74-php-brotli.x86_64 : Brotli Extension for PHP php74-php-fpm.x86_64 : PHP FastCGI Process Manager php74-php-pecl-ds.x86_64 : Data Structures for PHP php74-php-pecl-yaml.x86_64 : PHP Bindings for yaml php74-php-snappy.x86_64 : Snappy Extension for PHP php74-php-dbg.x86_64 : The interactive PHP debugger php74-php-pecl-druid.x86_64 : A Druid driver for PHP php74-php-pecl-leveldb.x86_64 : LevelDB PHP bindings ... ...
Enjoy it!