How to Install PHP 8 on Ubuntu 20.04/22.4 using Terminal


Install PHP 8 on Ubuntu 20.04/22.04. In this tutorial, you will learn how to install php 8 on ubuntu 20.04/22.04 system using the terminal.

This tutorial will help you step by step on how to install php 8 on ubuntu 20.04 with all the recommended repository using terminal or command prompt.

PHP is one of the most widely used server-side programming languages. Many popular CMS and frameworks such as WordPress, Magento, and Laravel are written in PHP.

Prerequisites

First install apache on ubuntu click here and read article how to install apache on ubuntu.

How to Install PHP 8 on Ubuntu 20.04/22.04 using Terminal

Follow the below steps and install php 8 on ubuntu 20.04/22.04 using terminal:

Step 1 – Enabling PHP Repository

In this step, you need to execute the following command on your terminal to enabling PHP repository:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Step 2 – Installing PHP 8.0

In this step, you need to exeucte the following command on your terminal to Installing the PHP on Ubuntu 20.04:

sudo apt-get update

Install The PHP 8 On Ubuntu with the below following command:

sudo apt install php8.0 libapache2-mod-php8.0

Step 3 – Configure Apache with PHP-FPM

In this step, you need to configure Php-FPM with apache by executing the following command to install the necessary packages:

sudo apt update
sudo apt install php8.0-fpm libapache2-mod-fcgid

By default PHP-FPM is not enabled in Apache. To enable it, run:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm

To activate the changes, restart Apache:

systemctl restart apache2

Step 4 – Test Installed PHP Version

In this step, execute the following command on terminal to check PHP version installed on your server:

php -v

Conclusion

Installing PHP 8 on Ubuntu 20.04/22.04 server is a simple task. All you need to do is to enable the “ondrej/php” repository and install PHP 8 with apt.

Recommended Ubuntu Posts

If you have any questions or thoughts to share, use the comment form below to reach us.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?