installphp.info


← Back to home page

Install PHP 8.2 on Debian 11

Warning! This version of PHP is outdated.

PHP 8.2 reached end of active support on 31 Dec 2024. As of today, PHP 8.2 is only receiving security related updates through 31 Dec 2026, 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.2 on Debian 11

Prerequisites

  • Debian 11 (Bullseye) installed and updated
  • Root or sudo access to the system
  • Terminal access
  • Internet connection

Installation

  1. Update the system packages:
    sudo apt update && sudo apt upgrade -y
  2. Install required packages:
    sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2
  3. Add the Sury PHP repository:
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
  4. Import the repository GPG key:
    wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
  5. Update the package list:
    sudo apt update
  6. Install PHP 8.2 and common extensions:
    sudo apt install -y php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-mbstring php8.2-mysql php8.2-xml

Verification

  1. Check the installed PHP version:
    php -v
  2. Verify PHP configuration:
    php -i
  3. Check installed PHP modules:
    php -m
  4. Create a test PHP file:
    echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/phpinfo.php
  5. Access the phpinfo file through a web browser to verify the installation and configuration.