Easy Way To Install PHP 7.3 on Ubuntu 22.04

In this tutorial, we want to teach you How To Install PHP 7.3 on Ubuntu 22.04. Installing PHP 7.3 on Ubuntu 22.04 is an essential step for developers and administrators who need to run PHP applications that depend on this specific version. While Ubuntu 22.04 supports more recent PHP versions by default, it’s entirely possible to add and manage PHP 7.3 for compatibility purposes.

PHP 7.3 introduced many syntax features to make development easier, added the ability to throw an exception when parsing or encoding JSON, added support for same-site cookies, improved FastCGI Process Manager (php-fpm) logging, expanded LDAP controls, provided case-mapping and case-folding support in mbstring functions, provided some improvements to password hashing, and updated its PCRE library.

Steps To Install PHP 7.3 on Ubuntu 22.04

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Ubuntu 22.04.

Add PPA Ondrej Repository on Ubuntu 22.04

Here we will install PHP 7.3 from the PPA repository.

PPA stands for Personal Package Archive. The PPA allows application developers and Linux users to create their repositories to distribute software. With PPA, you can easily get newer software versions or software that are not available via the official Ubuntu repositories.

First, add the PPA repo on Ubuntu 22.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

Install PHP 7.3 on Ubuntu 22.04

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

sudo apt-get install -y php7.3

Ubuntu PHP 7.3 – Verify Installation

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-8+ubuntu22.04.1+deb.sury.org+1 (cli) (built: Oct 28 2022 18:26:03) ( 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-8+ubuntu22.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

As you can see, you have successfully installed PHP 7.3. Let’s see where are the PHP.ini configuration files on Ubuntu 22.04.

php.ini Configuration Files on Ubuntu 22.04

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

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 22.04 are located in the following directories:

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

Also, you can list available modules with PHP on Ubuntu by using the following command:

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

Note: The executable PHP binaries on Ubuntu 22.04 are located in the following directories:

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

For more information, you can visit the PHP Documentation page.

Conclusion

By following these steps, you can successfully install PHP 7.3 on Ubuntu 22.04, maintaining the compatibility and stability of your applications. You can easily add the PPA repository and install PHP versions available on your server. Also, the current stable version of PHP is PHP 8.3. You can easily follow this link to get the latest version of PHP on Ubuntu 22.04. It is always recommended to stay updated and use the latest versions.

Hope you enjoy it. Also, you may like these articles:

How To Install PHP 7.4 on Ubuntu 22.04

How To Install PHP 7.4 on AlmaLinux 8

Install PHP 7.4 on Debian 11

Newsletter Updates

Enter your email address below and subscribe to our newsletter

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Stay informed and not overwhelmed, subscribe now!