ZeroStopBits

How to Upgrade PHP 5.4 to PHP 7.3 on CentOS 7.5 (1804)

This tutorial will show you how to upgrade PHP 5.4 to PHP 7.3 on CentOS 7.5 (1804).

I’m assuming that you are running a stock installation of CentOS, and already have PHP 5.4 installed.

1. Verify current version of PHP

Type in the following to see the current PHP version:

php -v

The output should match this:

PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Cool, let’s move on!

2. Install the REMI and EPEL repositories

If you don’t already have them, install the Remi and EPEL repositories:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm

Enable the Remi repository globally:

nano /etc/yum.repos.d/remi.repo

Under the section that looks like [remi] make the following changes:

[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Type CTRL-O to save and CTRL-X to close the editor

Enable the Remi PHP7.3 Repository:

nano /etc/yum.repos.d/remi-php73.repo

Under the section that looks like [remi-php73] make the following changes:

[remi-php73]
name=Remi's PHP 7.3 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php73/$basearch/
mirrorlist=https://rpms.remirepo.net/enterprise/7/php73/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php73/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Make sure you un-comment the HTTPS mirror-list as well. The HTTP mirror seems to run into issues every now and then.

Type CTRL-O to save and CTRL-X to close the editor

3. Upgrade PHP 5.4 to PHP 7.3

Now we can upgrade PHP. Just type in the following command:

yum -y upgrade php*

Once the upgrade has completed, verify that you have PHP 7.3 installed:

php -v

Output should look like:

PHP 7.3.0RC5 (cli) (built: Nov  6 2018 10:22:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies

You’re now running with PHP 7.3!

12 Comments

Christopher Vasanth

Thanks for the instructions. It worked on Centos 7. However, the output of phpinfo(); shows the older version 5.4.16

David Templeton

Restart apache to see the changes.

systemctl restart httpd.service

Ricardo Queiroz

It happens to me also, how did you resolve it? Does it need to disable the older version and enable the new one?

Warprider

Thanks for providing, wondering why default repo doesnt contatin highest version of PHP… Is 5.4 the most stable? Thanks!

denburda

The only working and simple solution. Thanks a lot, man!

Peter Nyiri

Hi,
I tried this on my VPS for PHP 7.4, but the last step doesn’t work:

user@web01.saadhost.com ~$ yum -y upgrade php*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.atlanticmetro.net
* epel: mirror.metrocast.net
* extras: mirror.atlanticmetro.net
* remi-php72: repo1.ash.innoscale.net
* remi-php73: repo1.ash.innoscale.net
* remi-php74: repo1.ash.innoscale.net
* remi-safe: repo1.ash.innoscale.net
* updates: mirror.atlanticmetro.net
No packages marked for update

user@web01.saadhost.com ~$ php -v
PHP 7.3.12 (cli) (built: Nov 30 2019 19:45:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
with the ionCube PHP Loader + ionCube24 v10.3.8, Copyright (c) 2002-2019, by ionCube Ltd.

Julian B

Same issue as Christopher Vasanth, php-v show current version, phpinfo() show older version.

Rob

Huh. I get:
# yum -y upgrade php*
Loaded plugins: product-id, search-disabled-repos, subscription-manager
remi-safe | 3.0 kB 00:00:00
remi-safe/primary_db | 1.7 MB 00:00:02
No packages marked for update

# rpm -qa | grep php
php-cli-5.4.16-46.1.el7_7.x86_64
php-common-5.4.16-46.1.el7_7.x86_64
php-5.4.16-46.1.el7_7.x86_64
php-pgsql-5.4.16-46.1.el7_7.x86_64
php-pdo-5.4.16-46.1.el7_7.x86_64

# php -v
PHP 5.4.16 (cli) (built: Oct 29 2019 10:01:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.7 (Maipo)

Padma

Even for me the last command didn’t work!
yum -y upgrade php*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.atlanticmetro.net
* epel: mirror.metrocast.net
* extras: mirror.atlanticmetro.net
* remi-php72: repo1.ash.innoscale.net
* remi-php73: repo1.ash.innoscale.net
* remi-php74: repo1.ash.innoscale.net
* remi-safe: repo1.ash.innoscale.net
* updates: mirror.atlanticmetro.net
No packages marked for update

Any suggestion?

Walter

Many, many thanks, it worked for me!

Girish Shenoy

Beautiful sir. much appreciate a simple and effective writeup as this.

Steve

great article thanks… it got me sorted out but then i hit an error at the end of the installation:

Create new NagiosQL database
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘1’, ‘0’, ‘1’, ‘1’, ‘1’, ‘1’, ”, NOW())’ at line 1

Database server connection (privileged user) passed (mysqli)
Database server version 5.5.68-MariaDB
Database server support supported
Delete existing NagiosQL database done (db_nagiosql_v35)
Creating new database done (db_nagiosql_v35)
Installing NagiosQL database tables done
Create NagiosQL database user done (Only added rights to existing user: nagiosql_user)
Set initial NagiosQL Administrator failed

any ideas how to correct this?

Comments are closed. Need a hand with something? Contact us.

Need a server to practise on?

Spin up a KVM VPS and follow along with any of these tutorials without risking your production boxes.