How to Install PHP 8 on Ubuntu 20.04?

Jun 25, 2022 . Admin

Hi Guys,

In this article we will cover on how to implement Ubuntu 20.04 on Install PHP 8. In this article, we will implement a Guide to Install PHP 8 on Ubuntu 20.04. This tutorial will give you simple example of Using Commands to Install PHP 8 on Ubuntu 20.04. I’m going to show you about Using Terminal Install PHP 8 on Ubuntu 20.04.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Follow the steps below and install php 8:

Step 1: Enabling PHP Repository

Type the following command to enable the PHP repository

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
Step 2: Installing PHP 8.0

Type the following command on your terminal to install

sudo apt-get update

Install The PHP 8 On Ubuntu with the below following command:

sudo apt install php8.0 libapache2-mod-php8.0
Step 3: Configure Apache with PHP-FPM

Configure Php-FPM with apache by executing the following command to install the necessary packages:

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

PHP-FPM is not enabled in Apache. To enable it, run:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm

To activate the changes, restart Apache:

systemctl restart apache2
Step 4: Test Installed PHP Version

Run the following command on the terminal to check the installed PHP version:

php -v
#Ubuntu