Home » How To Install & Upgrade to PHP 8.2 on Debian 11 / Debian 10

In this guide, we will show you how to install and upgrade PHP 8.2 for Debian 11 / Debian 10.

popular general-purpose scripting language that is especially suited to web development.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.


As with any new version, upgrading to PHP 8.2 can provide access to improved language features, performance enhancements, and security updates.

Note: This guide is specifically for 8.2, but it may also work for other versions of PHP as well.

Backup your data

Before we begin, it is very important to create a backup in case anything happens. That way, we can easily restore and not lose any data. Another option would be to create a clone to act as a test server so we don’t interfere with the live/production site.

Install PHP 8.2 on Debian 11 / Debian 10

This section will outline the process of installing PHP 8.2 on the Debian 11 (Bullseye) and Debian 10 (Buster) Linux systems.

Note: If you are upgrading PHP, it is a good idea to write down the current PHP version. You can find this by running the following command:

php -v

1. Add the Sury PPA Repository

The initial step entails adding the PPA containing the latest PHP packages and installing the prerequisite dependency packages.

Note: If you are running as the root user, please remove “sudo” from these commands

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

Following this, import the repository GPG key:

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Append the repository to the sources list:

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

To make sure it is working correctly:

sudo apt update

2. Installation of PHP 8.2 Packages

Once you successfully add the repository, PHP 8.2 can be installed using the following command:

sudo apt install php8.2

Upgrade PHP version to 8.2

Find the current PHP version

Find the current PHP version for WordPress

You can visit your yoursite.com/wp-admin/site-health.php?tab=debug and view the PHP version under the Server Tab

Find the currently installed php versions

php versions are installed in the /etc/php directory. To find what php versions you have installed currently, run the following command:

ls /etc/php

Upgrade the PHP version for WordPress/Apache

Disable the old PHP version

sudo a2dismod php7.2

Enable the new PHP version

sudo a2enmod php8.2

Restart the Apache webserver to propagate changes

sudo systemctl restart apache2

Cleanup of the old PHP

Now to finish off the installation, we should remove the old PHP version(s)

sudo apt purge php7.2*


We hope this guide helped you to install and upgrade your PHP version on Debian 11 / Debian 10. Please leave a comment if you have any questions and feel free to check out our other homelab guides.
Happy Hacking!

About Author

Leave a Reply

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