How To Install PHP 7.3 On Debian 9 / Debian 8

This short tutorial is for installing PHP 7.3 on Debian 9 (Stretch) and Debian 8 (Jessie). With PHP 7.3 comes a number of bug fixes, new functionalities and features as well as a number of deprecations.

For Ubuntu 18.04 / Ubuntu 16.04, use:

Install PHP 7.3 on Debian 9 / Debian 8

Follow the steps provided below to install 7.3 on Debian 9 / Debian 8

Step 1: Update system and Install add-apt-repository

Ensure your system is updated:

sudo apt update
sudo apt upgrade -y

If you don’t have add-apt-repository command available in your system, install it using our guide below:

Step 2: Add  PHP 7.3 PPA repository

Once the add-apt-repository command is available, add PHP 7.3 PPA 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/php7.3.list

Step 3: Install PHP 7.3 on Debian 9 / Debian 8

The last step is to Install PHP 7.3 on Debian 9 / Debian 8. First, run the apt update command:

$ sudo apt update
 Hit:2 https://packages.sury.org/php stretch InRelease
 Ign:1 https://cdn-fastly.deb.debian.org/debian stretch InRelease
 Hit:3 https://cdn-fastly.deb.debian.org/debian stretch Release
 Reading package lists… Done
 Building dependency tree 
 Reading state information… Done
 4 packages can be upgraded. Run 'apt list --upgradable' to see them.

Then install  PHP 7.3 on Debian 9 / Debian 8:

sudo apt -y install php7.3

Check version installed

$ php -v
 PHP 7.3.0-2+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec 17 2018 09:22:47) ( NTS )
 Copyright (c) 1997-2018 The PHP Group
 Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
     with Zend OPcache v7.3.0-2+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Step 4: Installing PHP 7.3 Extensions

Install PHP 7.3 extensions by using the syntax

 sudo apt install php7.3-<entension-name>

See example below which install standard PHP extensions.

sudo apt install php7.3-cli php7.3-fpm php7.3-json php7.3-pdo php7.3-mysql php7.3-zip php7.3-gd  php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-json

To install Apache Module for PHP, run:

sudo apt install libapache2-mod-php7.3

Confirm one:

$ apt policy php7.3-cli
 php7.3-cli:
   Installed: 7.3.0-2+ubuntu18.04.1+deb.sury.org+1
   Candidate: 7.3.0-2+ubuntu18.04.1+deb.sury.org+1
   Version table:
  *** 7.3.0-2+ubuntu18.04.1+deb.sury.org+1 500
         500 https://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages
         100 /var/lib/dpkg/status

Congratulations!!. You have successfully installed PHP 7.3 on Debian 9 / Debian 8.

Rolar para cima