How to update / upgrade to PHP 7.3 on Debian 9?

Upgrade to PHP 7.3 on Debian 8 and Debian 9

This short tutorial is used to install PHP 7.3 on Debian 9 and Debian 8. With PHP 7.3 several bugs are fixed, new functionalities come and obsolete repairs in your dependencies.

Update your Debian VPS

First of all you must have your system updated

sudo apt update
sudo apt upgrade -y


Add the PHP 7.3 repository

sudo apt -y install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
echo "deb$ (lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Update your system again

The last step to install PHP 7.3 on Debian 9 and Debian 8 is to update your system again, but with the added dependencies:

sudo apt update

Check the current version of your system

php -v

PHP 7.3.29-1 + 0 ~ 20210701.86 + debian9 ~ 1.gbp7ad6eb (cli) (built: Jul 1 2021 16:11:36) (NTS) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.29, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.29-1 + 0 ~ 20210701.86 + debian9 ~ 1.gbp7ad6eb, Copyright (c) 1999-2018, by Zend Technologies

(Optional) Add libraries or extensions.

Find the libraries you need and install the same as in other versions of PHP

Sudo apt install php7.3- <extension name>