How to Install PHP 8.1 on Ubuntu 22.04?

By Hardik Savani May 14, 2024 Category : Ubuntu

Hey Guys,

This tutorial shows you how to install php 8.1 on ubuntu 22.04. we will help you to give an example of install php 8.1 on ubuntu 22.04. you will learn how to install php 8.1 in ubuntu 22.04. In this article, we will implement a ubuntu 22.04 install php 8.1.

As of October 2021, there is no official release of Ubuntu 22.04. The latest stable version is Ubuntu 21.10 (Impish Indri). However, you can still install PHP 8.1 on Ubuntu 21.10 by following these steps. I will give you just simple few step to install php 8.1 in ubuntu 22.04.

Let's see the simple steps:

Step 1: Run System Updates

To ensure that our repositories are up to date, the first step in a new system is to update them. Additionally, it is essential to run the upgrade command.

sudo apt update

Step 2: Add Ondrej Sury PPA Repository

To run PHP 8.1 on Ubuntu 22.04, it is necessary to include Ondrej Sury's PPA in our system. Ondrej Sury is currently responsible for maintaining the PHP repository. However, please note that this PPA is not currently verified, so there is no guarantee of obtaining 100% reliable results when installing from it.

To add this PPA, execute the following command in our terminal.

sudo apt install software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt update

Step 3: Install PHP 8.1 and Common Extensions

We should now be able to install PHP 8.1 on Ubuntu 22.04 Linux machine. The commands to run are as shared below:

sudo apt install php8.1

sudo apt install php8.1-cli php8.1-common php8.1-json php8.1-opcache php8.1-mysql php8.1-mbstring php8.1-zip php8.1-fpm php8.1-xml php8.1-bcmath php8.1-gd php8.1-curl php8.1-intl php8.1-redis php8.1-imagick

Now, you can check your php version using following command:

php -v

I hope it can help you...

Tags :