The objective is to install or replace existing PHP 5 with PHP 7 on CentOS 7 Linux server. As you will see, this procedure is fairly simple when using Remi Repository.
Privileged access to your CentOS Linux system either directly as root user or via
command is required.
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
- $ - requires given linux commands to be executed as a regular non-privileged user
The following guide will either upgrade your current PHP 5 to PHP 7 or will install new PHP 7 on your CentOS system. Check your current PHP version ( if applicable ):
# php --version
PHP 5.4.16 (cli) (built: Nov 6 2016 00:29:02)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
SUBSCRIBE NEWSLETTER & RSS
Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.
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
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
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
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
Below you can find the video tutorial on how to install PHP 7 on CentOS 7 Linux system.