Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 9 - Install Later Versions Of PHP

The easiest way to install later versions of PHP is to add Ondrej's repository.

sudo apt install ca-certificates apt-transport-https -y
wget -q -O- | sudo apt-key add -
echo "deb stretch main" | sudo tee /etc/apt/sources.list.d/php.list

Removing Existing PHP

If you had already installed PHP from native packages remove it before installing the later version:

sudo apt-get remove php7.0 php7.0-* -y
sudo apt autoremove -y

Install PHP 7.3

sudo apt-get update && \
sudo apt install php7.3-cli libapache2-mod-php7.3

Install PHP 7.2

sudo apt-get update && \
sudo apt install php7.2-cli libapache2-mod-php7.2


Last updated: 9th June 2019
First published: 27th May 2019