installphp.info


← Back to home page

Install PHP 7.4 on Debian 12

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

PHP 7.4 reached end of life on 28 Nov 2022 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.4 on Debian 12

Prerequisites

  • Root access or sudo privileges on your Debian 12 system
  • A working internet connection
  • Basic familiarity with the command line interface

Installation

  1. Update the package list:
    sudo apt update
  2. Install the software-properties-common package:
    sudo apt install software-properties-common
  3. Add the Ondřej Surý PPA repository:
    sudo add-apt-repository ppa:ondrej/php
  4. Update the package list again:
    sudo apt update
  5. Install PHP 7.4 and common extensions:
    sudo apt install php7.4 php7.4-cli php7.4-common php7.4-curl php7.4-mbstring php7.4-mysql php7.4-xml

Verification

  1. Check the installed PHP version:
    php -v
  2. Verify PHP CLI is working:
    php -r "echo 'PHP is working';"
  3. Check installed PHP modules:
    php -m

If all steps are successful, PHP 7.4 is now installed and ready to use on your Debian 12 system.