How To Install PHP 7 Using YUM ON CentOS/RHEL 7?

PHP 7 is one the latest version of PHP in IT industry and many modules/ libraries function has been deprecated in PHP7.0. This newer version of PHP 7.0.16 was made public on 11th May 2017 for CentOS/RHEL. PHP 7 got support for PEAR install and pecl has got deprecation so webtatic repository keeps deprecated libraries for support.

Here with the end of this article, we will learn how to install PHP7.0 on CentOS/RHEL 7.x using YUM from Webtatic repository.

Scenario: My Server IP is 192.168.1.188
OS CentOS: 7.0.1

Note: If you are a SUDO user then prefix every command with sudo, like #sudo ifconfig

Step1: Install Required repositories

To install PHP 7.0 we require Webtatic EL repository and EPEL repository will be required as a dependency for this repository installation:

#rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Step 2: Install PHP With Webtatic

After first step 1, you can install PHP 7.0 with a simple command.

#yum install php70w php70w-opcache

Step 3: Look For PHP Modules

As PHP7.0 is installed but your application may require a various module to process. PHP 7 also have a list for a wide variety of useful libraries and modules which you can add to your PHP. If you want to look for available PHP modules type in the following command:

#yum search php70

Output Will be

Loaded plugins: priorities, update-motd, upgrade-helper
============== N/S matched: php70 ===================
php70w.x86_64
php70w-bcmath.x86_64
php70w-cli.x86_64
php70w-common.x86_64
php70w-dba.x86_64
php70w-devel.x86_64
php70w-embedded.x86_64
php70w-enchant.x86_64
php70w-fpm.x86_64
php70w-gd.x86_64
php70w-imap.x86_64
php70w-interbase.x86_64
php70w-intl.x86_64
php70w-ldap.x86_64
php70w-mbstring.x86_64
php70w-mcrypt.x86_64
php70w-mysql.x86_64
php70w-opcache.x86_64
php70w-pdo.x86_64
php70w-pdo_dblib.x86_64
php70w-pear.noarch
php70w-pecl-apcu.x86_64
php70w-pecl-apcu-devel.x86_64
php70w-pecl-igbinary.x86_64
php70w-pecl-igbinary-devel.x86_64
php70w-pecl-imagick.x86_64
php70w-pecl-imagick-devel.x86_64
php70w-pecl-memcached.x86_64
php70w-pecl-mongodb.x86_64
php70w-pecl-redis.x86_64
php70w-pecl-xdebug.x86_64
php70w-pgsql.x86_64
php70w-phpdbg.x86_64
php70w-process.x86_64
php70w-pspell.x86_64
php70w-recode.x86_64
php70w-snmp.x86_64
php70w-soap.x86_64
php70w-tidy.x86_64
php70w-xml.x86_64
php70w-xmlrpc.x86_64

Step 4: Install A module

Now as per your production and deployment requirement you can install any module listed. Here we are installing php70w-opcache and php70w-fpm as an example.

#yum install php70w-fpm php70w-opcache

Well, Congratulations! You have successfully Installed PHP 7.0


Step 5: Check Your Installation

As you have successfully installed our custom PHP version, we need to verify its version and location of installation

#which php

Output Window will be like:

/usr/bin/php

Also, check which version of PHP your shell is using:

#php -v

Output Window:

PHP 7.0.19.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Watch Video:

YouTube Link

You may also Like

  1. How To Install PHP using YUM
  2. How To Set Up LAMP Environment With Apache MySql And PHP: Part-1

Watch Video

Source [PHP Site]