This short tutorial will guide you through installing PHP 7.3 on Debian 9 and Debian 8. PHP 7.3 fixes several bugs, introduces new features, and addresses obsolete dependencies.

Update your Debian VPS

First, you must ensure your system is up to date.

sudo apt update

sudo apt upgrade -y

Repository

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 https://packages.sury.org/php/apt.gpg

echo \"deb https://packages.sury.org/php/ $(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 your current system version


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 them as you would in other PHP versions.
 sudo apt install php7.3-
` ...