The PHP 7.4 is the latest stable release of PHP. The CentOS 7 official software repositories have PHP 5.5 which has reached the end of life and no longer actively maintained by the developers.

Firstly, we will need to enable epel repo and then remi repo. Use the following command to install EPEL repository on your CentOS and Red Hat 7 systems:

# yum install epel-release

Then install remi repository:

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

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

For now, we have installed latest version PHP 7.4

# 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 Technologies

Then you can install corresponding PHP extensions:

# yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

You can check the modules/extensions using below command:

# php -m

By anup

Leave a Reply

Your email address will not be published. Required fields are marked *