3 Methods to Install the Latest PHP 7 Package on CentOS/RHEL 7 and CentOS/RHEL 6
======
PHP is the most popular open-source general-purpose scripting language and is widely used for web development.
It’s part of the LAMP stack application suite and is used to create dynamic websites.
Popular CMS applications WordPress, Joomla and Drupal are developed in PHP language.
These applications require PHP 7 for their installation and configuration.
PHP 7 loads your web application faster and consumes less server resources.
By default the CentOS/RHEL 6 operating system provides PHP 5.3 in their official repository and CentOS/RHEL 7 provides PHP 5.4.
In this article we will show you how to install the latest version of PHP on CentOS/RHEL 7 and CentOS/RHEL 6 systems.
This can be done by adding the necessary **[additional third-party RPM repository][1]** to the system.
### Method-1 : How to Install PHP 7 on CentOS 6/7 Using the Software Collections Repository (SCL)
The SCL repository is now maintained by a CentOS SIG, which rebuilds the Red Hat Software Collections and also provides some additional packages of their own.
It contains newer versions of various programs that can be installed alongside existing older packages and invoked by using the scl command.
Run the following **[yum command][2]** to install Software Collections Repository (SCL) on CentOS
```
# yum install centos-release-scl
```
Run the following command to verify the PHP 7 version available in the scl repository.
```
# yum --disablerepo="*" --enablerepo="centos-sclo-rh" list *php
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
centos-sclo-rh: centos.mirrors.estointernet.in
Available Packages
php54-php.x86_64 5.4.40-4.el7 centos-sclo-rh
php55-php.x86_64 5.5.21-5.el7 centos-sclo-rh
rh-php70-php.x86_64 7.0.27-2.el7 centos-sclo-rh
rh-php71-php.x86_64 7.1.30-2.el7 centos-sclo-rh
rh-php72-php.x86_64 7.2.24-1.el7 centos-sclo-rh
```
Run the command below to install the PHP 7.2 on your system from scl.
If you need to install additional modules for PHP 7.2, you can install them by running the command format below. For instance, you can install the **“gd”** and **“pdo”** packages by executing the command below.
Run the command below to search the available PHP 7 version from the RHSCL repository.
```
# yum search rh-php*
```
You can easily install PHP 7.3 on the RHEL 7 machine by running the command below from the RHSCL repository.
```
# yum install rh-php73
```
### Method-2 : How to Install PHP 7 on CentOS 6/7 Using the Remi Repository
The **[Remi repository][3]** stores and maintains the latest version of PHP packages with a large collection of libraries, extensions and tools. Some of them are back-ported from Fedora and EPEL.
This is a CentOS community-recognized repository and doesn’t modify or affect any underlying packages.
As a prerequisite, this installs the **[EPEL repository][4]** if it is not already installed on your system.
You can easily find the available version of the PHP 7 package from the Remy repository because it adds a separate repo to each version. You can view them using the **[ls command][5]**.
### Method-3 : How to Install PHP 7 on CentOS 6/7 Using the IUS Community Repository
IUS Community is a CentOS Community Approved third-party RPM repository which contains latest upstream versions of PHP, Python, MySQL, etc.., packages for Enterprise Linux (RHEL & CentOS) 5, 6 & 7.
**[IUS Community Repository][6]** have dependency with EPEL Repository so we have to install EPEL repository prior to IUS repository installation. Follow the below steps to install & enable EPEL & IUS Community Repository to RPM systems and install the packages.
EPEL package is included in the CentOS Extras repository and enabled by default so, we can install this by running below command.
```
# yum install epel-release
```
Download IUS Community Repository Shell script
```
# curl 'https://setup.ius.io/' -o setup-ius.sh
% Total % Received % Xferd Average Speed Time Time Time Current