PHP, which is a recursive acronym for PHP Hypertext Preprocessor, is a popular server-side scripting language used for web development. It is an HTML embedded language and finds its use in a wide range of websites and web apps.

The most popular use of PHP has been in the world of Content Management Systems (CMS). The most used CMS software in the world, WordPress, uses PHP. Other popular CMS software like Drupal and Joomla also use PHP and various PHP libraries.

A user needs to install PHP on his Ubuntu 20.04 machine if he/she wishes to install any such software which uses PHP, or if the user wants to develop his/her own web application.

In this article, we will see how to install PHP on Ubuntu 20.04 LTS.


The PHP interpreter, command-line interpreter and all required libraries are a part of the php package on Ubuntu 20.04. Before we get started, let’s first update the repositories.

sudo apt update

Let’s install the package php now.

sudo apt install php

Note that, if you are looking for a particular version for PHP, for example, PHP 7.3 or PHP 7.4, they have separate packages in Ubuntu repositories with the name php7.3, php7.4, etc. You can install them from this package. The resultant PHP interpreter binary files will also be named similarly, i.e., php7.3, php7.4.

sudo apt install php7.3

That being said, the package php will always contain the latest version of PHP available in Ubuntu repositories.

Verifying the Installation

Run the command php with the flag -v (version) to check if it is successfully installed.

php -v

Similarly, if you have installed a different version, run the PHP command for that version, which is always named in the format php<version_number>.

php7.3 -v

That’s it! PHP is now successfully installed in your system. You can begin developing PHP based applications, or setup applications which require PHP, eg. WordPress or Drupal.

Note that if you are using PHP for development purposes, the package php does not install all the PHP libraries, rather it only installs most commonly used libraries. You need to manually install other required libraries from their respective packages using apt install. These packages follow the nomenclature php-<library_name>, eg. php-curl. To search for all such packages, run apt search php.