Installing PHP8 on ubuntu 22.04 LTS

Introduction

PHP is an open-source language, which means that it is free to use and modify, and has a large community of developers who contribute to its ongoing development. It is widely used in web development, powering popular content management systems like WordPress and Drupal, as well as e-commerce platforms like Magento and WooCommerce.

Prerequisites

  • Basic knowledge of Linux commands.
  • Up and running Ubuntu 22.04 Machine
  • Root permission

In this post, We will show you how to install PHP 8 on ubuntu 22.04 LTS Linux machine.

Step 1: Run System Update

We need to 1st update and upgrade the current ubuntu repository to avoid difficulties situations, Use the given command for the same.

To update ubuntu repository.

sudo apt-get update

To upgrade packages (Optional)

sudo apt-get upgrade -y

Step 2: Installing Dependencies

We need to install 1st required packages by using given commands.

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

Step 3: Setup PHP Repository

Use the following command in order to add the PHP’s repository in your ubuntu machine.

sudo add-apt-repository ppa:ondrej/php

Here we need to press Enter button to continue.

Step 4: Installing PHP 8

We have now added the PHP repository and installed the necessary dependencies. Following this, we will proceed with the PHP 8 installation on our Ubuntu 22.04 system:

sudo apt-get install php8.0 -y

Step 5: Verify PHP Version

The “php” command can also be used to check the version of the installed PHP by using the “-v” option:

php -v

Step 6: Installing PHP 8 Extensions

Ubuntu is a Linux-based system that lets PHP 8 extensions be installed to make it more useful.

In order to install PHP 8 extensions, you need to use the syntax that is listed below:

sudo apt-get install php8.0-<extension>

For instance, the following syntax will be used to install some PHP 8 extensions:

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

Step 7: Check PHP 8 Loaded Modules

Use the following command to check PHP 8’s loaded modules:

php -m

Conclusion

We have successfully installed PHP8 on ubuntu 22.04 LTS, if you still have questions, please post them in the comments section below.

Author

Installing PHP8 on ubuntu 22.04 LTS

4 thoughts on “Installing PHP8 on ubuntu 22.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top