# 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
sudo apt-get-repository ppa:ondrej/php
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
# 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.
# PHP -v
Run the command php -v to test if PHP has been installed successfully.
# 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
To get the list of modules installed with PHP, you can run the following command
# 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
Put the following code in the index.php file
<?php phpinfo(); ?>
# PHP Installation Location
The executable PHP Binaries are installed in the /usr/bin directory
The Additional PHP modules are installed in /usr/share directory
/usr/share/php7.3-json /usr/share/php7.3-common /usr/share/php7.3-readline
Ini files for PHP and different modules are available under /etc/php directory
/etc/php/7.3/mods-available/pods.ini /etc/php/7.3/mods-available/json.ini ...
That’s all about Installing PHP on your Ubuntu Machine