How to Install PHP 8 on Ubuntu 20.04

Install PHP 8 on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure PHP 8 on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

PHP is a recursive acronym for Hypertext Preprocessor and is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. Many popular CMS and frameworks such as WordPress, Laravel, and many more are built in PHP. As of right now, PHP 8.0 is on track to be released on November 26th, 2020. The release process is in feature freeze now and we’ll have 4 betas and 5 release candidates before we get the final version ( for all the dates).


  • Operating System with Ubuntu 20.04
  • Server IPv4 Address with Superuser Privileges (Root Access)
  • Gnome Terminal for Linux Desktop
  • PuTTy SSH client for Windows or macOS
  • Powershell for Windows 10/11
  • Familiar with APT Commands

Install PHP 8 on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common

Step 2. Install PHP 8 on the Ubuntu system.

Now add the PPA repository which has the latest build packages of PHP:

sudo add-apt-repository ppa:ondrej/php
sudo apt update

Once the update adds repository completely, let’s begin the PHP installation:

sudo apt install php8.0

After the installation has completed, you can confirm the installation using the following command

php -v

Step 3. Installing PHP extensions.

PHP extensions are compiled libraries that extend the core functionality of PHP. Extensions are available as packages and can be easily installed with apt:

sudo apt install php8.0-[module]

For example:

sudo apt install php8.0-{bz2,curl,intl,mysql,readline,xml}

Step 4. Testing PHP Processing

First, create a test PHP file called info.php in the webserver default home directory:

sudo nano /var/www/html/info.php

And add the following code:


After that, open your browser and browse to the server hostname or IP address followed by the name of the file you created above:


That’s all you need to do to install the PHP on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on PHP 8, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.