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.
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
mcryptextension. Other than that, PHP 7.3 includes all extensions that were in PHP 7.1 and 7.2.
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.
2. Install PHP 7.3
PHP 7.3 core
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.
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-fpmpackage. 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
Nginx and Apache with
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.
4. Remove old PHP versions
With new PHP 7.3 installed, you can remove your old PHP versions if you want.
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.