How to Install PHP 8.0 on Ubuntu 20.04

Install PHP 8.0 on Ubuntu
Php installation on Ubuntu

PHP is among the most widely used server-side programming languages. The most popular CMS(Content Management System) WordPress also built with PHP. In this tutorial, I am going to explain how to install PHP 8.0 on Ubuntu 20.04 step by step, so let’s dive in.

How to Install PHP 8.0 on Ubuntu 20.04

Step 1: Enabling Ondřej Surý PPA Repository

Currently PHP 7.4 is the default PHP version in Ubuntu 20.04 repositories. To install the latest version of PHP we have to run following commands

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

Next, add the PPA

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

Press “Enter” on the keyboard.

Install PHP 8.0 on Ubuntu

Step 2: Install PHP 8.0 with Apache on Ubuntu

Now again update the system with following command

$ sudo apt update

Now install PHP 8.0 with the Apache module as below.

$ sudo apt install php8.0 libapache2-mod-php8.0 

After installation complete, restart the Apache server again with following command.

$ sudo systemctl restart apache2

If you want to enable apache with PHP-FPM, run below command

$ sudo apt install php8.0-fpm libapache2-mod-fcgid

By default PHP-FPM not enable, to make it enable run following command

$ sudo a2enmod proxy_fcgi setenvif
$ sudo a2enconf php8.0-fpm

Now restart Apache again to effect the changes

$ sudo systemctl restart apache2

Step 3: Install PHP 8 Extensions in Ubuntu

Some extensions comes with the packages. Download them by following command.

$ sudo apt install php8.0-[extension-name]

Install Memcached, MySQL and GD extensions

$ sudo apt install php8.0-mysql php8.0-gd php-memcached

Step 4: Check PHP version to verify

To make sure, you installed correct version of PHP in your linux machine, run following command

$ php -v

Now, PHP should be installed on your server.


In this tutorial you have learned PHP 8.0 installation. If you like this article, please feel free to share and also comment, if you have any question.

Read Here


Please enter your comment!
Please enter your name here