installphp.info


← Back to home page

Install PHP 8.1 on Debian 11

Warning! This version of PHP is outdated.

PHP 8.1 reached end of active support on 25 Nov 2023. As of today, PHP 8.1 is only receiving security related updates through 31 Dec 2025, at which point it will be considered end-of-life and receive no further updates. It's strongly recommended to upgrade to the latest version of PHP before then.

Installing PHP 8.1 on Debian 11

Prerequisites

  • Debian 11 (Bullseye) installed and updated
  • Root access or a user with sudo privileges
  • Terminal access

Installation

  1. Add the Sury PHP repository:

    sudo apt update
    sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common
    sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
  2. Update the package list:

    sudo apt update
  3. Install PHP 8.1 and common extensions:

    sudo apt install -y php8.1 php8.1-cli php8.1-common php8.1-curl php8.1-mbstring php8.1-mysql php8.1-xml

Verification

  1. Check the installed PHP version:

    php -v
  2. Verify PHP configuration:

    php -i
  3. Check installed PHP modules:

    php -m