How to Install PHP 8 on Debian 11

Update the Debian 11 using the following command.

apt update

To Add SURY PHP PPA repository.

First, download the GPG key.

apt -y install lsb-release apt-transport-https ca-certificates 
wget -O /etc/apt/trusted.gpg.d/php.gpg

Next, add SURY to the repository.

echo "deb $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list


root@server:~# echo "deb $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list

deb bullseye main

Install PHP 8

Ensure the added package is up to date.

apt update

If any update is available update the system and reboot.

apt upgrade -y && reboot

To install PHP 8.

apt -y install php8.0

To check the PHP version.

php -v


root@server:~# php -v
PHP 8.0.9 (cli) (built: Jul 30 2021 13:09:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies with Zend OPcache v8.0.9, 
Copyright (c), by Zend Technologies

Installing PHP Extensions

Install PHP Extensions by running the following command

apt install php8.0-<extension>

NOTE: Replace the required extensions name like below command

apt install php8.0-apcu


root@server:~# apt install php8.0-apcu
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  php-apcu-bc php7.4-apcu php7.4-apcu-bc php7.4-common

To list installed php modules/extensions.

php -m


  • PHP configurations related to Apache is stored in /etc/php/8.0/apache2/php.ini this file.

  • If you want to use PHP with Nginx you can follow this guide Click here.

This concludes our topic of installing PHP 8 on the Debian 11 system.