Cantech Knowledge Base

Your Go-To Hosting Resource

How To Install PHP 8 on Debian 11?

The Hypertext Preprocessor (PHP) stands as a broadly-utilized open-source server-side scripting language developed mainly for web development purposes. This language stands out due to its straightforward design combined with adaptable functionality and effective performance which establishes it as a leading choice for developing dynamic web content.

This blog provides a step by step guide on how to install php8 on debian server text.

Follow these steps, to install PHP 8 on Debian 11:

Prerequisites

  • A Debian 11 system with administrative (root) privileges.
  • An updated package index.

PHP 8 Installation on Debian 11

Firstly, to install PHP 8 on Debian, you need to set up the deb.sury.org repository.

Add the Repository Key

wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -

Next, add the repository using the command

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

Update the package index.

sudo apt update

PHP 8.0 has to be installed from the deb.sury.org repository.

sudo apt install php8.0

Check the PHP 8 Installation

php -v

Extensions

Extensions are added to get new functionalities on PHP

To check the list of installed extensions

php -m

Check the extension list, to find the available extension

Add apt to install the extension

sudo apt install php8.0-{extension name}

Example

sudo apt install -y php8.0-mysql

Please refer to the official documentation for more information on PHP 8.

March 19, 2025