Install/Upgrade to PHP 7.3 - Ubuntu & Debian

Published On08 Nov 2018

Upgrade to PHP 7.3 on Ubuntu and Debian

I wrote posts about updating Debian & Ubuntu systems to PHP 7.1 and 7.2. It's time for a similar post for PHP 7.3. PHP 7.3 is expected to be released on December 6, but I have been trying it out for a few months now. You can also take a look at What's new and changing in PHP 7.3 that turned out to be a quite comprehensive list of what's new, deprecated, and changed in PHP 7.3. This guide is pretty much similar to the PHP 7.1 and 7.2 upgrade guides.


Because PHP 7.3 is not released to the masses yet, there can be several bugs in it, I highly recommend you not upgrade your production servers to PHP 7.3 yet. I have personally come across a few mysterious bugs myself, so be warned.

1. Add ondrej/php PPA

As usual, we use the awesome PHP PPA by Ondrej. He publishes PHP 7.3 on all supported Ubuntu versions and Debian Stretch and Jessie.

sudo add-apt-repository ppa:ondrej/php # Press enter to confirm.
sudo apt update
sudo apt install apt-transport-https lsb-release
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg # Download the signing key 
sudo sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # Add Ondrej's repo to sources list. sudo apt update

2. Note down current PHP packages

If you are upgrading PHP from an earlier version, it's important to make sure you ensure you have the same PHP extensions installed. PHP 7.2 onwards no longer include mcrypt extension. Other than that, PHP 7.3 includes all extensions that were in PHP 7.1 and 7.2. dpkg -l | grep php | tee packages.txt Above command will list all packages installed in your system that has php in its name, and write them to a file called packages.txt in your current working directory. You can easily refer this file to install the same PHP 7.3 package counter parts.

3. Install PHP 7.3

Now to the juicy part!

PHP 7.3 core

sudo apt install php7.3 php7.3-common php7.3-cli

This will install PHP 7.3 core extensions and PHP 7.3 CLI.

PHP 7.3 extensions

You can now install the remaining packages as necessary. If you are setting up a new setup, or have no clear idea which packages to install, I highly recommend installing the following packages from the command below. If you are upgrading, look at the packages.txt file to see your current list.

apt install php7.3-bcmath php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-readline php7.3-xml php7.3-zip

PHP 7.3 for web server

With all these packages in place, you might also need to integrate PHP with your web server. If you are using Nginx, or Apache with mod_event, you will need to install php7.3-fpm package. If you are using PHP as an embedded Apache module, you will need libapache2-mod-php7.3 package. For Apache, you can run apachectl -V to see your current MPM, whether its prefork or event.

Nginx and Apache with event MPM
apt install php7.3-fpm
Apache with prefork MPM
apt install libapache2-mod-php7.3

3. Test if PHP 7.3 is properly installed

Once everything is installed, run php -v to make sure PHP 7.3 (CLI) is installed.

Output of PHP 7.3 'php -v' command.

4. Remove old PHP versions

With new PHP 7.3 installed, you can remove your old PHP versions if you want.

apt purge php7.2 php7.2-common # Change 7.2 with whatever current version you have.

So that's it, you should have PHP 7.3 running. Note that automatic upgrades (unattended-upgrades) will not work on Ondrej's PPA, so you still need to manually upgrade your PHP versions.

Make sure to run apt update and apt upgrade to upgrade to the latest PHP version. If you run into unexpected bugs related to PHP 7.3, see What's new and changing in PHP 7.3 that might answer what caused the surprise.

Recent Articles on PHP.Watch

All ArticlesFeed 
How to fix `mysql_native_password` not loaded errors on MySQL 8.4

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to fix the SQLSTATE[HY000] [1524] Plugin 'mysql_native_password' is not loaded errors caused in MySQL 8.4 no longer enabling the mysql_native_password plugin by default.
How to fix PHP Curl HTTPS Certificate Authority issues on Windows

How to fix PHP Curl HTTPS Certificate Authority issues on Windows

On Windows, HTTPS requests made with the Curl extension can fail because Curl has no root certificate list to validate the server certificates. This article discusses the secure and effective solutions, and highlights bad advice that can leave PHP applications insecure.
AEGIS Encryption with PHP Sodium Extension

AEGIS Encryption with PHP Sodium Extension

The Sodium extension in PHP 8.4 now supports AEGIS-128L and AEGIS256 Authenticated Encryption ciphers. They are significantly faster than AES-GCM and CHACHA20-POLY1305. This article benchmarks them and explains how to securely encrypt and decrypt data using AEGIS-128L and AEGIS256 on PHP.
Subscribe to PHP.Watch newsletter for monthly updates

You will receive an email on last Wednesday of every month and on major PHP releases with new articles related to PHP, upcoming changes, new features and what's changing in the language. No marketing emails, no selling of your contacts, no click-tracking, and one-click instant unsubscribe from any email you receive.