Table of Contents
How to install and configure PHP on Ubuntu 20.04 Linux Servers.
In this tutorial, we will look at how to install and configure PHP on Ubuntu 20.04 and Linux virtual servers. And in PHP versions 7.2, 7.3, and 7.4, install and configure.
How to Work, install and configure PHP on Ubuntu 20.04
After installing the full version of PHP, you can install multiple versions of PHP on the Ubuntu system according to your needs to change PHP versions.
Step 1) Add PHP PPA with two the command below
First, need is updating package:
sudo apt update
Then you need to configure repository on your system:
sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php
If you successfully update and complete the installation, we will move on to the second step.
Step 2) Install Required PHP Version (PHP 7.2, PHP 7.3, PHP 7.4)
You can install the desired version according to the following steps:
Install PHP 7.2
To install this version need is that’s run the command below:
sudo apt install php7.2
Install PHP 7.3
PHP 7.3 is a current active release of PHP on the Ubuntu. For the install this version run the command below:
sudo apt install php7.3
Install PHP 7.4
PHP 7.4 is the latest stable version available for installation. To install this version on the Ubuntu VPS Server, run the command below:
sudo apt install php7.4
Note: It is recommended that you upgrade your programs before installing PHP versions so that you do not have any problems.
Step 3) Check PHP Version
After completing the installation steps, you can check the php version with the following command:
php -v
Step 4) Switch Between PHP Versions
For the use of update-alternatives command to set the default PHP version, use the command below:
update-alternatives --config php
Congratulations, you can successfully install and configure PHP on Ubuntu 20.04.