If you have a barebones install of CentOS 7 with PHP or need to install the latest PHP, it’s super easy with the REMI Yum Repository.

Download Remi and EPEL Repository packages

First, download Remi and EPEL Repository packages:

$ wget -q http://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ wget -q https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ yum -y install yum-utils yum-config-manager

Enable Remi and EPEL Repository

Install both previously downloaded packages and enable Remi PHP 7 repo:

# rpm -i remi-release-7.rpm epel-release-latest-7.noarch.rpm
FOR PHP 7.0 EXECUTE:
# yum-config-manager --enable remi-php70
FOR PHP 7.1 EXECUTE:
# yum-config-manager --enable remi-php71
FOR PHP 7.2 EXECUTE:
# yum-config-manager --enable remi-php72
FOR PHP 7.3 EXECUTE:
# yum-config-manager --enable remi-php73  

Current latest PHP version from Remi repository is 7.1. Amend the above command for any other subsequent PHP releases.

Install or Upgrade to PHP 7

Whether you already have PHP 5 installed on your system or you are performing a new PHP 7 installation, the below command will cater for both:

# yum install php

Alternatively, upgrade entire system with yum update command:

# yum update

Check your current PHP version

# php --version
PHP 7.1.0 (cli) (built: Dec  1 2016 08:13:15) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies