How to Install Latest PHP 7.3 on Ubuntu 18.04

In this tutorial, we will learn How to Install Latest PHP 7.3 on Ubuntu 18.04.

The latest current stable release of PHP is 7.3 which was released on 1 August 2019. After one month of the release, Ubuntu default repositories still do not have the latest version of PHP. By default, Ubuntu 18.04 is having PHP 7.2 as the latest version of PHP.

You can also check the Current Stable Release of PHP here.

We are assuming that you already have Ubuntu 18.04 installed. If not then you can follow this tutorial for installing the Ubuntu 18.04.

Ubuntu 18.04 LTS Desktop Installation with Screenshots

1. Get installed version of PHP

So, At very first let’s check the currently installed version of PHP with the below command.

root@iswblog:~# php -v

You should have this type of output if PHP is installed in your system.

PHP 7.2.15-0ubuntu0.18.04.1 (cli) (built: Feb  8 2019 14:54:22) ( NTS )
 Copyright (c) 1997-2018 The PHP Group
 Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
     with Zend OPcache v7.2.15-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

2. Add the PPA for latest PHP

Now we add PPA (Personal Package Archives) of the PHP for the latest stable version which is PHP 7.3. Let’s add the PPA with the below command.

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

You can get more info about ondrej/PPA here.

Now update the repositories for listing the new packages.

sudo apt update

You can also confirm that the latest PHP packages are added in the list. Check with the below command.

root@iswblog:~# apt list | grep php7.3

You should get a result like below.

libphp7.3-embed/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64
php7.3-bcmath/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64
php7.3-cgi/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64
php7.3-dba/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64
php7.3-dev/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64
php7.3-enchant/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64
php7.3-fpm/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64
php7.3-gmp/bionic 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 amd64

3. Install PHP 7.3 on Ubuntu 18.04 and Verify

Finally, Now you can install the PHP 7.3 Version. Install it by the below command.

root@iswblog:~# apt install php

If you want to install any extra module like php-gd or php-json you can install them using below commands.

root@iswblog:~# apt install php7.3-gd php7.3-bcmath php7.3-json

So, Now let’s check our installation by the below command.

trifid@db3:~$ php -v
PHP 7.3.8-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Aug  7 2019 09:52:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.8-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

You should get the above output. So, you have successfully installed the latest stable version of PHP in Ubuntu 18.04 LTS version.

Summary :

PHP is one of the widely used programming language and nearly the most used language for web application development. So, it’s better to stay updated because it’s also having the dark past. In the tutorial, we see how we can install PHP 7.3 on Ubuntu 18.04 LTS. The installation procedure is the same for both the Ubuntu Desktop or Ubuntu Server.

Thanks for Reading. Happy Learning !!!

Recommended : How to upgrade to python 3.7 on Ubuntu 18.10

1 thought on “How to Install Latest PHP 7.3 on Ubuntu 18.04”

Leave a Comment