How To Install PHP 7.4, 7.3 & 7.2 on CentOS/RHEL 7
Abstract: A module for PHP applications for using the GNU MPA module for PHP applications for using the bcmath
PHP 7.4 is the latest stable release of PHP. May of popular yum repositories is providing rpm packages for PHP 7. This article is using Remi and EPEL yum repositories for installing the required packages on your system. This article will help you to install PHP 7.4, PHP 7.3, PHP 7.2, PHP 7.1 on CentOS & Redhat 7 servers. This tutorial has been tested with CentOS Linux release 7.4.1708.
- Install PHP7, Nginx and MySQL on CentOS/RedHat
First of all, you need to enable Remi and EPEL yum repositories on your system. Use the following command to install EPEL repository on your CentOS and Red Hat 7/6 systems
Use this command to install EPEL yum repository on your system
sudo yum install epel-release
and now execute one of the following commands as per your operating system version to install the Remi repository.
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpmInstall PHP 7 on CentOS
Your system is prepared for the PHP installation from yum repositories. Use one of the following commands to install PHP 7.4 or PHP 7.3 or PHP 7.2 or PHP 7.1 on your system based on your requirements.
## Install PHP 7.4 yum --enablerepo=remi-php74 install php ## Install PHP 7.3 yum --enablerepo=remi-php73 install php ## Install PHP 7.2 yum --enablerepo=remi-php72 install php ## Install PHP 7.1 yum --enablerepo=remi-php71 install php
I have installed the latest version PHP 7.4 on my system. Now running the following command to check the current active PHP version on my system.
php -v PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend TechnologiesInstall PHP Modules
You may also need to install additional PHP modules based on your application requirements. The below command will install some more useful PHP modules.
### For PHP 7.4 yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt ### For PHP 7.3 yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt ### For PHP 7.2 yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt ### For PHP 7.1 yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
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.4.
yum --enablerepo=remi-php73 search php | grep php73 * remi-php74: repo1.ash.innoscale.net php74.x86_64 : Package that installs PHP 7.4 php74-php.x86_64 : PHP scripting language for creating dynamic web sites php74-php-bcmath.x86_64 : A module for PHP applications for using the bcmath php74-php-brotli.x86_64 : Brotli Extension for PHP php74-php-cli.x86_64 : Command-line interface for PHP php74-php-common.x86_64 : Common files for PHP php74-php-componere.x86_64 : Composing PHP classes at runtime php74-php-dba.x86_64 : A database abstraction layer module for PHP applications php74-php-dbg.x86_64 : The interactive PHP debugger php74-php-devel.x86_64 : Files needed for building PHP extensions php74-php-embedded.x86_64 : PHP library for embedding in applications php74-php-enchant.x86_64 : Enchant spelling extension for PHP applications php74-php-fpm.x86_64 : PHP FastCGI Process Manager php74-php-gd.x86_64 : A module for PHP applications for using the gd graphics php74-php-gmp.x86_64 : A module for PHP applications for using the GNU MP php74-php-imap.x86_64 : A module for PHP applications that use IMAP php74-php-intl.x86_64 : Internationalization extension for PHP applications php74-php-json.x86_64 : JavaScript Object Notation extension for PHP ... ...