Install PHP Using Apt/Terminal
This is the simplest method, we use apt package manager to install the PHP into the Ubuntu system, The following are the steps involved:
Step 1: Open Terminal with Sudo Rights
The first step is to open the Ubuntu terminal and apply sudo rights, To open the terminal (Ctrl+Alt+T) type the following command, then enter the system’s user password:
sudo -i
This will give us the following output:
Step 2: Update Repository
Now run the following commands to update the index and repository for the latest repositories using the following command:
sudo apt update
This will give us the following output:
Step 3: Install PHP Package
Now you have to run the following apt command and it will automatically install the PHP in the Ubuntu system:
sudo apt install php
This will give us the following output:
Step 4: Check if PHP is Installed or Not
This is the final step where we will now check if PHP is installed or not, for this, you will simply have to run the following command:
php -v
This will give the following output:
Note: If the PHP version is different then there is no issue, PHP is successfully installed in your system.
How to Install PHP on Ubuntu?
Installing PHP in Ubuntu is a very simple and efficient process estimate we already know, PHP is responsible for the development of various web applications it is considered one of the most popular languages for web development, in this article we will learn and understand how we can install the PHP in the ubuntu.
Table of Content
- What is PHP?
- Prerequisites
- How to Install PHP in Ubuntu?
- Method 1: Install PHP Using Apt/Terminal
- Method 2: Install PHP Using Apache on Ubuntu