Home  »  ArticlesGuidesHow ToLibrariesTechnology   »   How To Install PHP 8.2 on Debian 11 | Debian 10

How To Install PHP 8.2 on Debian 11 | Debian 10

This tutorial will show you how to install PHP 8.2 on Debian 11 (Bullseye) and Debian 10 (Buster) Linux systems. If you are interested in installing PHP 8.2 on Ubuntu systems, we have a post for that as well as this post showing how to install on CentOS 7 and RHEL 7 based Linux systems.

PHP 8.2 is the most recent version of PHP released on December 8, 2022. This version comes with a host of new features, improvements, and bug fixes including but not limited to:

  • Readonly Classes: A class can be declared as readonly, making all of its properties to be automatically declared readonly
  • Type System Improvements: Added support for true type, and allowing null and false types to be used as stand-alone types as well as support for DNF types.
  • New random extension: This new feature provides a new OOP API to generate random numbers with a pluggable architecture.
  • Constants in Traits: It is now possible to declare constants in traits in In PHP 8.2.
  • Sensitive Parameter Value Redaction: This feature adds new built-in parameter Attribute named #[SensitiveParameter] that ensures PHP redacts the actual value in stack traces and error messages.
  • New Functions and Classes: New classes and functions such as ini_parse_quantity, curl_upkeep, openssl_cipher_key_length, and memory_reset_peak_usage are now included.
  • Dynamic Properties Deprecated: In PHP 8.2 class properties that are dynamically declared
  • utf8_encode and utf8_decode Functions are now deprecated

Install PHP 8.2 on Debian 11 / Debian 10

These are the steps to follow in order to install PHP 8.2 on Debian 11 (Bullseye) and Debian 10 (Buster) Linux systems.

Step 1. Add Sury PPA repository

Add the PPA that contains the latest PHP packages. Install dependency packages for this.

$ sudo apt update
$ sudo apt install lsb-release apt-transport-https ca-certificates software-properties-common -y

Install the tool to get the release.

$ sudo apt install lsb_release

Now we import repository GPG key and add the repository to your sources list.

$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg 
$ sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Update the package list.

$ sudo apt update

Step 2. Install PHP 8.2 Packages

Run the commands below to perform the installation:

$ sudo apt install php8.2

Run the following command to confirm the version of PHP currently installed on your Debian system.

$ php -v
PHP 8.2.4 (cli) (built: Mar 16 2023 14:37:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.4, Copyright (c), by Zend Technologies

Step 3. Install PHP 8.2 extensions

You can now install the PHP 8.2 extensions that you require. PHP extensions are libraries that provide extra functionality to the PHP programming language.

To install a PHP extensions you would need to run a command with the following syntax:

sudo apt install php8.2-<extension-name>

For example, assuming we want to install the following PHP extensions:

bz2, cli, common, curl, intl, mbstring, mysql, zip

The we would run the following command to install the above extensions:

$ sudo apt install php8.2-{bz2,cli,common,curl,intl,mbstring,mysql,zip}

We have a more comprehensive article showing how to install PHP modules in Ubuntu if you need more details. The steps highlighted in the article also apply to Debian based systems.


You now know how to install Install PHP 8.2 on Debian 11 | Debian 10 Linux systems. We have also shown you how to install PHP8.2 extensions to get the functionality you need. If you need to run your PHP with Nginx or Apache web servers, we have this tutorial showing you how to use PHP 8.2 with Nginx / Apache web servers.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.