How to upgrade PHP version on CentOS 7

This tutorial will show you how to upgrade PHP 5.4 to PHP 7.4 on CentOS 7.


To install PHP type the next command:

# yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

Type the following command to see the current PHP version:

# php -v PHP 5.4.16 (cli) (built: Nov 1 2019 16:04:20) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

As you can see the default PHP version is 5.4 And now we will update it.

Turn on Remi repo:

# yum install

Install yum-utils packages:

# yum install yum-utils

yum-utils includes yum-config-manager, which you can use to enable Remi repo as the default repository for installing different PHP versions.

If you want to install PHP 7.1, PHP 7.2, PHP 7.3 or PHP 7.4 on CentOS 7, just enable it as below.

# yum-config-manager --enable remi-php71 # yum-config-manager --enable remi-php72  # yum-config-manager --enable remi-php73 # yum-config-manager --enable remi-php74

For this tutorial we will choose PHP 7.4

# yum-config-manager --enable remi-php74

Now you should refresh repository:

# yum update

Checking PHP version one more time:

# php -v PHP 7.4.2 (cli) (built: Jan 21 2020 11:35:20) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies

Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 11789