Site icon AppTeam

How to install or upgrade to PHP 7 on CentOS 7 Linux Server

Objective

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.

Requirements

Privileged access to your CentOS Linux system either directly as root user or via sudo command is required.

Difficulty

EASY

Conventions

Instructions

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

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
FOR PHP 7.3 EXECUTE: 
# yum-config-manager --enable remi-php73
FOR PHP 7.4 EXECUTE: 
# yum-config-manager --enable remi-php74

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
Exit mobile version