How to install PHP version 7.2 on CentOS 7 / RHEL 7 Server

How to install PHP version 7.2 on CentOS 7 / RHEL 7 Server

 

On RHEL and CentOS servers you can install PHP 7.2 using yum command. Before installing PHP 7.2 you must enable EPEL (Extra Packages for Enterprise Linux) and Remi repository on your server.
You can either install EPEL repo by downloading the latest rpm package from the website https://fedoraproject.org/wiki/EPEL OR you can install EPEL using yum.
 
1. Log into your Linux server as ‘root’ user

2. First install EPEL repo using yum command.

Command to install EPEL repo :

# yum install epel-release

3. Download and install remi repository on your centos / Redhat server

Command to install remi-release :

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

4. Run the below command to install PHP 7.2 on your Linux server.

# yum --enablerepo=remi-php72 install php

5. Run the command ‘php -v’ to verify the version of PHP installed

——-
# php -v
PHP 7.2.17 (cli) (built: Apr 3 2019 10:02:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
——–