Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 9 - Upgrade To PHP 7.3

Run the following commands to add Ondrej's packages to your sources so that you can easily install PHP 7.3 packages.

sudo apt update && sudo apt install -y apt-transport-https lsb-release ca-certificates gnupg2

# Add Ondrej's GPG key to tell Debian you trust his packages.
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

# Now add Ondrej's PHP packages to your sources.
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

# Update your package list so you can install what you want later (doesn't update your packages themselves).
sudo apt update

Installing Apache And PHP 7.3 From Scratch

sudo apt dist-upgrade -y

sudo apt-get install libapache2-mod-php7.3 -y

# You may* also want these extensions.
sudo apt-get install php7.3-mysql php7.3-bcmath php7.3-zip php7.3-curl php7.3-mbstring php7.3-gd -y

# Start Apache
sudo service apache2 start

Replacing Apache + PHP 7.0 With Apache + PHP 7.3

The following commands are what I run to upgrade my Apache Wordpress Installation from PHP 7.0 to 7.3.

sudo apt dist-upgrade -y

# Now update and upgrade to PHP 7.3
sudo service apache2 stop

sudo apt-get remove libapache2-mod-php7.0 -y && sudo apt-get install libapache2-mod-php7.3 -y

sudo apt-get remove php7.0-*
sudo apt-get install php7.3-mysql php7.3-bcmath php7.3-zip php7.3-curl php7.3-mbstring php7.3-gd -y

sudo service apache2 start
Last updated: 23rd October 2022
First published: 22nd August 2019