HOW TO INSTALL PHP 8.X ON UBUNTU: STEP-BY-STEP GUIDE

PHP, a popular programming language for web development, constantly enhances with each new release, offering better features, performance, and security. The recent major update, PHP 8.x, includes many exciting enhancements and optimizations. If you use Ubuntu and want to upgrade to PHP 8.x, this article will help you through the installation process. By following the detailed steps below, you’ll have the latest PHP version up and running on your Ubuntu system quickly. Let’s Install PHP8.x on the Ubuntu Server by following these steps
Update System Packages:
It is always a good practice to keep your system updated with the latest packages. To start, let’s make sure our system is current. Open the terminal and execute the command below to refresh the package lists and update any existing packages:
sudo apt-get update && sudo apt-get upgrade
Add Ondrej Sury’s PHP PPA:
Here comes the main part of the job to Install PHP 8.x on the Ubuntu Server, adding the PPA repository. Next, we must include the PHP Personal Package Archive (PPA), which is kept up to date by renowned PHP developer Ondrej Sury. Ubuntu PHP packages that are current can be found in this PPA. To add the PPA, type the commands below into the terminal:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Install PHP 8.x:
Now that the PPA has been added, PHP 8 can be installed. x. Installing PHP and its required dependencies can be done by running the following command:
sudo apt-get install php8.2 -y
Verify the Installation
To ensure that PHP 8.2 has been successfully installed, we can confirm the version by running the following command:
php -v
The PHP version should appear, validating the installation.
You have successfully installed PHP version 8.x or more specifically PHP version 8.2.
If you want to install any other version of PHP simply name Version: 8.1 or 8.0, and you’ll get the desired package installed on your system, The rest of the procedure remains the same.
Also, check out how to update the Ubuntu release upgrade.