How to Install PHP 8.3 on Ubuntu 20.04

PHP is a script language and interpreter that is freely available and used primarily on Linux Web servers.

To install PHP 8.3, we’ll need to add/ PHP PPA repositories which contain the PHP 8.3 packages that we need.

Pre-requisites :

  • A system with Ubuntu 20.04 installed and running.

  • root access to the system.

To Ensure system updated.

apt update

If any update is available update the system and reboot.

apt upgrade -y && reboot

Add PHP PPA Repository

apt -y install software-properties-common

add-apt-repository ppa:ondrej/php

Output:

root@vps:~# apt install php8.3 -y

Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: amd64-microcode eatmydata intel-microcode iucode-tool libdbus-glib-1-2 libeatmydata1 libevdev2 libimobiledevice6 libplist3 libupower-glib3 libusbmuxd6 python3-importlib-metadata python3-jinja2 python3-json-pointer python3-jsonpatch python3-jsonschema python3-markupsafe python3-more-itertools python3-pyrsistent python3-zipp thermald upower usbmuxd Use 'apt autoremove' to remove them. The following additional packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php8.3 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0 php-common php8.3-cli php8.3-common php8.3-opcache php8.3-readline ssl-cert Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear openssl-blacklist The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php8.3 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0 php-common php8.3 php8.3-cli php8.3-common php8.3-opcache php8.3-readline ssl-cert 0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded. Need to get 4,506 kB/6,394 kB of archives. After this operation, 30.5 MB of additional disk space will be used. Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.3-common amd64 8.3.0-1+ubuntu20.04.1+deb.sury.org+1 [704 kB] Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.3-opcache amd64 8.3.0-1+ubuntu20.04.1+deb.sury.org+1 [338 kB]

Install PHP 8.3

Ensure the added package is up to date.

apt update

If any update is available update the system and reboot.

apt upgrade -y && reboot

Install PHP 8 on Ubuntu

apt install php8.3 -y

To check PHP Version.

php -v

Output:

root@vps:~# php -v

PHP 8.3.0 (cli) (built: Nov 24 2023 08:49:45) (NTS) Copyright (c) The PHP Group Zend Engine v4.3.0, Copyright (c) Zend Technologies with Zend OPcache v8.3.0, Copyright (c), by Zend Technologies

To Install php Extensions.

NOTE: Replace the required extensions name in the command

apt install php8.2-<extension>

To list installed php modules/extensions.

php -m

This concludes our topic of installing PHP 8.2 on the Ubuntu 20.04 system.