installphp.info


← Back to home page

Install PHP 8.1 on Debian 10

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 10

Prerequisites

  • Debian 10 (Buster) installed and updated
  • Root access or user with sudo privileges
  • Terminal access
  • Internet connection

Installation

  1. Update the package list:

    sudo apt update
  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 again:

    sudo apt update
  6. Install PHP 8.1:

    sudo apt install -y php8.1

Verification

  1. Check the installed PHP version:

    php -v
  2. Verify PHP configuration:

    php -i
  3. Create a test PHP file:

    echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/phpinfo.php
  4. Access the phpinfo page in your web browser:

    http://your_server_ip/phpinfo.php