How to Install PHP in Ubuntu 22.04?

How to Install PHP in Ubuntu 22.04?

PHP Scripting is a generic backend scripting language. Abbreviation for “hypertext preprocessor”. PHP is a scripting language which means it is used to create scripts on the backend of a server and helps manage the operations on the server. PHP creates dynamic web pages and it can access databases. PHP can be embedded inside HTML, and it enhances the functionality of HTML.

How to Install PHP in Ubuntu 22.04?

To install PHP in Ubuntu 22.04 we have listed two methods to give you a better understanding of it.

  • Install PHP via official repository
  • Install PHP via PPA repository method

Method 1: How to Install PHP in Ubuntu 22.04 via Official Repository Method?

A repository which contains deb packages for the installation on Ubuntu and other Linux distros, and that packages are only accessible using APT tools. We have compiled the steps to install PHP in Ubuntu 22.04 using official repository.

Step 1: Update System Packages

Before moving towards the installation, we need to update system packages:

sudo apt update

Step 2: Install PHP

Now, after updating system packages, install PHP by the use of command below:

sudo apt install php -y

The PHP installation has been completed.

Step 3: Check PHP version

Now, to verify the installation of PHP:

php –version

Method 2: How to Install PHP in Ubuntu 22.04 Using the PPA Repository Method?

PPA basically stands for Personal Package archives, the big benefit of this is that it allows creators to create their own packages. These PPA packages are easier to install than other third party apps. We have compiled the steps to install PHP in Ubuntu 22.04 using PPA repository.

Step 1: Update System Packages

Before moving towards installation, firstly update system packages:

sudo apt update

System packages updated successfully.

Step 2: Add PPA Repository of PHP

Add the PPA repository of PHP by running the below code:

sudo add-apt-repository ppa:ondrej/php

After running the command above the PPA repository has been added.

Step 3: Install PHP

Now, install PHP in Ubuntu 22.04 by running the below code:

sudo apt install php -y

PHP has been installed on Ubuntu 22.04.

Step 4: Check PHP version

Execute the below command to check the version of PHP:

php –version

The output shows the version of PHP, which confirms that PHP is installed successfully.

How to Uninstall PHP from Ubuntu 22.04?

To uninstall PHP from Ubuntu 22.04, just execute the below command:

sudo apt autoremove php *purge -y

PHP has been uninstalled from Ubuntu 22.04.

Conclusion

The programming language PHP is utilized to develop dynamic websites. In order to manage server operations, PHP is used to write scripts on the server side. Two methods are described in this article to install PHP in Ubuntu 22.04. First method is by using an official repository and the second is by using the PPA repository method.

 

admin Avatar

Liyana Parker

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.