Install PHP 8 on Ubuntu 22.04

October 25, 2022 · 0 min read
Install PHP 8 on Ubuntu 22.04
PHP, or Hypertext Preprocessor, is an open-source, general-purpose programming language that is widely used for web development jobs. PHP 8 was released for general use on November 26, 2020. It has a number of optimizations and wonderful features such as named arguments, attributes, match expressions, union types, JIT, error-handling, type system, and consistency enhancements.

Update system repositories

To update the system repositories, use the command shown below.

sudo apt update

Install all necessary prerequisites

Following the update of the system packages, the following requirements for PHP 8 must be installed

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

Set up PHP repository

Then, use the following command to add the PHP 8 repository to your system repositories:

sudo add-apt-repository ppa:ondrej/php

To allow the prompt to continue, press "Enter":

Install PHP 8 on Ubuntu 22.04

We have now installed the necessary dependencies and added the PHP repository. We'll now proceed to install PHP 8 on our Ubuntu 22.04 machine using the instructions below.
To enable the system to finish installing PHP 8, type "y":

sudo apt install php8.1

Verify PHP version

You can check the version of PHP that is installed by using the "php" command with the "-v" option

php -v


First, update the system repositories and install the essential components before installing PHP 8 on Ubuntu 22.04. Then, add the PHP repository by running "$ sudo add-apt-repository ppa:ondrej/php" and install PHP 8 by running "$ sudo apt install php8.1." You may enhance your web development experience by installing its available extensions.