installphp.info


← Back to home page

Install PHP 7.3 on Debian 12

Warning! This PHP version is end-of-life!

PHP 7.3 reached end of life on 06 Dec 2021 and is no longer being updated. It's strongly recommended to upgrade to the latest version as soon as possible. You can read the official PHP migration guide here.

Installing PHP 7.3 on Debian 12

Prerequisites

  • A Debian 12 system with root or sudo access
  • Terminal access to the system
  • Basic knowledge of command-line operations

Installation

  1. Update the package list:

    sudo apt update
  2. Install the necessary dependencies:

    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 7.3 and common extensions:

    sudo apt install -y php7.3 php7.3-cli php7.3-common php7.3-curl php7.3-mbstring php7.3-mysql php7.3-xml

Verification

  1. Check the installed PHP version:

    php -v

    You should see output indicating PHP 7.3.x is installed.

  2. Verify PHP CLI is working:

    php -r "echo 'PHP is working!';"

    This should output: PHP is working!

  3. Check installed PHP modules:

    php -m

    This will list all installed PHP modules.