How to Install PHP v 7.3 on Ubuntu 20.04

# TL;DR version

Here is the short version of setting up PHP version 7.3 on your Ubuntu Machine (I am currently on v 20.04)

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.3

# Detailed Version

Installing PHP 7.3 on Ubuntu v 20.04

Here are the steps.

# 1. Add PPA repository

Open the terminal and add the following repository

Livewire Component Library
sudo apt-get-repository ppa:ondrej/php

sudo apt-add-repository ppa php

Host Laravel Application on DigitalOcean

Use coupon 5balloons on this Cloudways Affiliate URL to get special discount.

# 2. Run apt-get update

The sudo apt-get update command is used to download package information from all configured sources. Run the apt-get update command to download the latest package information.

sudo apt-get update

sudo apt-get update

# 3. Install PHP

The next and final step is to install PHP, Run the following command in your terminal.

sudo apt-get install -y php7.3

This command will download the given version of PHP from the repository and will install on the local Ubuntu machine.

sudo apt-get install -y php 7.3

# PHP -v

Run the command php -v to test if PHP has been installed successfully.

php -v

php -v ubuntu

# PHP.ini Location

Once PHP is installed you may want to know the location of PHP.ini configuration file. PHP.ini holds all the default configuration of PHP and editing this file can be used to override the default values.

Here is the location where PHP is installed


There are two php.ini configuration file in your PHP installation, one for the CLI (Command line interface) and another for the Web (Apache2). Following are the location of both php.ini files



# Additional Modules Installed

Following are the additional modules that got installed as part of PHP dependencies

  • libapr1:amd64
  • libaprutil1:amd64
  • libaprutil1-dbd-sqlite3
  • libaprutil1-ldap:amd64
  • apache2-bin
  • apache2-data
  • apache2-utils
  • apache2
  • php-common
  • php7.3-common
  • php7.3-json
  • php7.3-opcache
  • php7.3-readline
  • php7.3-cli
  • libapache2-mod-php7.3

To get the list of modules installed with PHP, you can run the following command

php -m

# PHP Built-in WebServer

PHP comes with a builtin HTTP WebServer , To test the PHP script, create a new folder and create new file named index.php inside it.

Open the terminal and navigate to the newly created directory and run the following command

php -S localhost:8000

This will fire up the server on port 8000, You can now access the PHP webpage in your browser by going to http://localhost:8000
Put the following code in the index.php file


phpinto output

# PHP Installation Location

The executable PHP Binaries are installed in the /usr/bin directory


The Additional PHP modules are installed in /usr/share directory


Ini files for PHP and different modules are available under /etc/php directory


Modules INI


That’s all about Installing PHP on your Ubuntu Machine

Site Footer