Install PHP in Apache Server Ubuntu 20.04

PHP installation in Apache server is easy. If you are Ubuntu 20.04 operating system in your cloud hosting, then following step by step guide is going to help you to install PHP.

PHP Installation

Installing PHP only is not sufficient to run a web application which has PHP as server side scripting. We need libapache2 mod php and php mysql along with php software package. So lets proceed to install them.

Instead of running three different commands we can run single command to install PHP, libapache2 mod php and PHP MySQL.

Before installing any software, it is good practice to install updates.

Therefore following single line command would install updates and also install PHP, libapache2 mod php and PHP MySQL.

(Login to your Ubuntu with non root user with super user privilege. If you have no idea about it then check the second chapter of this tutorial series. All the chapter list is present below this article)

test@tester:~$ sudo apt update && sudo apt install php libapache2-mod-php php-mysql

It may take couple of minutes to install and then it is ready.

Lets check whether PHP has been installed successfully or not. Use following command.

test@tester:~$ php -version

Output

PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

The above command tells php 7.4 is installed.

Hope, the above article helps you to install PHP software package in Apache Server (Ubuntu 20.04).