How to Install PHP 8.2 on Ubuntu 22.04

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

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

Pre-requisites :

  • A system with Ubuntu 22.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:~# add-apt-repository ppa:ondrej/php
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu/ jammy main'
Description:
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

IMPORTANT: The <foo>-backports is now required on older Ubuntu releases.

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

Install PHP 8.2

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.2 -y

To check PHP Version.

php -v

Output:

root@vps:~# php -v
PHP 8.2.0 (cli) (built: Dec 10 2022 10:53:01) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
  with Zend OPcache v8.2.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 22.04 system.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS