How to Install PHP 8 on Ubuntu 22.04

PHP or Hypertext Preprocessor is an open-source, general-purpose programming language primarily utilized for the tasks related to web development. On November 26, 2020, PHP 8 has been officially released for public usage. It comprises several optimizations and fantastic features such as named arguments, attributes, match expression, union types, JIT, error-handling, type system, and consistency improvements.

This post will discuss the procedure to install PHP 8 on Ubuntu 22.04. So, let’s start!

How to install PHP 8 on Ubuntu 22.04

For the installation of PHP 8 on Ubuntu 22.04, you must follow the below-given step-by-step instructions.

Step 1: Update system repositories

Press “CTRL+ALT+T” to open the terminal of your Ubuntu 22.04 and run the below-given command to update system repositories:

$ sudo apt update

Step 2: Install required dependencies

After updating the system packages, the next step is to install required dependencies for PHP 8:

$ sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y

The specified dependencies will be installed in a few minutes:

Step 3: Set up PHP repository

Then, set up the PHP 8 repository on your system repositories with the help of the following command:

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

Press “Enter” to permit the prompt to continue:

Step 4: Install PHP 8 on Ubuntu 22.04

At this point, we have installed the required dependencies and added the PHP repository. Now, we will move ahead and execute the below-given for PHP 8 installation on our Ubuntu 22.04 system:

$ sudo apt install php8.0

Type “y” to allow the system for completing PHP 8 installation:

Step 5: Verify PHP version

You can also verify the version of the installed PHP by executing the “phpcommand with the “-v” option:

$ php -v

As you can see from the output, PHP 8 is all set up on our Ubuntu 22.04 system:

Step 6: Install PHP 8 Extensions

As a Linux-based system, Ubuntu permits the installation of PHP 8 extensions to enhance its functionality.

You have to follow the below-given syntax for the installation of PHP 8 extensions:

$ sudo apt install php8.0-<extension>

For instance, we will use the given syntax for installing some PHP 8 extensions as follows:

$ sudo apt install php8.0-cli php8.0-common php8.0-imap php8.0-redis php8.0-xml php8.0-zip php8.0-mbstring

Wait for a few minutes until the installation of PHP 8 extensions gets complete:

Step 7: Check PHP 8 loaded modules

To check the loaded modules of PHP 8, utilize the following command:

$ php -m

Step 8: Check php-fpm status

If you want to use PHP 8 with Nginx then before doing so check if the “php-fpmservice is currently active or not:

$ systemctl status php*-fpm.service

On our Ubuntu 22.04 system, the “php-fpmservice is active which can be seen in the below-given output:

We have compiled the simplest method for PHP 8 installation on Ubuntu 22.04. Give it a try and start web development.


For the installation of PHP 8 on Ubuntu 22.04, firstly update the system repositories and install the required dependencies. Then, add the PHP repository using the “$ sudo add-apt-repository ppa:ondrej/php” command and install PHP 8 by executing the “$ sudo apt install php8.0” command. You can install its available extensions for improving the web development experience. This post discussed the method to install PHP 8 on Ubuntu 22.04.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.