Sunday, October 2, 2022

How To Install PHP 7.3 on Ubuntu 20.04

In this article, we want to teach you How To Install PHP 7.3 on Ubuntu 20.04.

PHP is an open-source server-side scripting language that many devs use for web development.

It is also a general-purpose language that you can use to make lots of projects, including Graphical User Interfaces (GUIs).

The abbreviation PHP initially stood for Personal Homepage. But now it is a recursive acronym for Hypertext Preprocessor.

PHP is mostly used for making web servers. It runs on the browser and is also capable of running in the command line. So, if you don’t feel like showing your code output in the browser, you can show it in the terminal.

How To Install PHP 7.3 on Ubuntu 20.04

Before you start to set up PHP 7.3 on Ubuntu 20.04, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Ubuntu 20.04.

Now follow the steps below to set up PHP 7.3 on your server.

Set up PHP 7.3 on Ubuntu 20.04

Here you will install PHP 7.3 from the PPA repository. First, add PPA repo on Ubuntu 20.04 with the following command:

sudo add-apt-repository ppa:ondrej/php

Then, update your local package index with the command below:

sudo apt-get update

Now you can use the following command to install PHP 7.3:

sudo apt-get install -y php7.3

When you are done, check your PHP 7.3 installation by checking its version:

php -v

In your output you will see:

Output
PHP 7.3.33-1+ubuntu20.04.1+deb.sury.org+1 (cli) (built: Nov 19 2021 06:25:05) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.33-1+ubuntu20.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

The location of the PHP installed on your Ubuntu 20.04 is /etc/php/7.3.

And there are two ini configuration files for PHP. One for the CLI (Command-line interface) and another for the Web (Apache2).

/etc/php/7.3/apache2/php.ini /etc/php/7.3/cli/php.ini

The ini modules files for PHP on Ubuntu 20.04 are located in the:

/etc/php/7.3/mods-available/pods.ini
/etc/php/7.3/mods-available/json.ini
...

Also, you can list available modules with PHP with the command below:

php -m

In your output you will see:

Output
[PHP Modules]
calendar
Core
ctype
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib
[Zend Modules]
Zend OPcache

The executable PHP binaries on Ubuntu 20.04 are located in the:

/usr/bin/php
/usr/bin/php7.3

Conclusion

At this point, you learn to set up PHP 7.3 on Ubuntu 20.04.

Hope you enjoy it.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles