How to Install PHP 8.0 and 8.1 on Ubuntu 18.04 and 20.04

How to Install PHP 8.0 on Ubuntu

In this tutorial, we will learn how to install PHP 8.0 and PHP 8.1 on Ubuntu 18.04 and 20.04 with modules.

PHP is one of the most used server-side scripting languages all over the world. Many popular software and packages are developed in PHP such as Laravel, Magento and WordPress, etc.

PHP 8.1 is the latest PHP version which offers a lot of optimization and improvement in PHP code.

The following command will work for both Ubuntu 18.04 and Ubuntu 20.04.

Enabling PHP Repository

To install PHP 8.0 and PHP 8.1 first we need to enable the Repository. Repositories store the package’s version by version.

  • Run the following command to enable the repository.
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
  • Update the List of packages
sudo apt update

Install PHP 8.0

sudo apt install php8.0 php8.0-mysqli php8.0-intl php8.0-mbstring php8.0-gd php8.0-xml php8.0-imap php8.0-zip php8.0-curl php8.0-ldap php8.0-mysqlnd php8.0-opcache -y

Install PHP 8.1

sudo apt install php8.1 php8.1-mysqli php8.1-intl php8.1-mbstring php8.1-gd php8.1-xml php8.1-imap php8.1-zip php8.1-curl php8.1-ldap php8.1-mysqlnd php8.1-opcache -y
  • To check the installed modules of PHP, run the following command.
php -m
  • If you have installed the multiple PHP version on the server then you can check them with the following command
apt list --installed | grep php


In this tutorial, we have learned how to install the latest PHP 8.0 and 8.1 in Ubuntu 18.04 and 20.04 with PHP modules. The installation process is the same for both Ubuntu 18.04 and 20.04. PHP plays a major and important role from both the sides of Frontend(Website) and Backend(Server).

If you guys have any queries related to this tutorial then let me know in the comments.