How To Install PHP 7.4 on Debian 10 / Debian 9

Quick Summary

  • This legacy guide installs PHP 7.4 on Debian 9 or 10; PHP 7.4 reached end of life on 28 November 2022, and Debian 9 and 10 left LTS in June 2022 and June 2024.
  • packages.sury.org no longer serves Debian 9 or 10, so the repository steps now fail; the Sury FAQ points to the paid PHP LTS by Freexian for these releases.
  • For a supported setup, follow How to install PHP on Debian: PHP 8.4 on Debian 13, PHP 8.2 on Debian 12, or another version from the Sury repository.

Legacy guide. This guide installs PHP 7.4 on Debian 9 (stretch) or Debian 10 (buster), and all three have reached end of life: PHP 7.4 stopped getting fixes on 28 November 2022, Debian 9’s LTS support ended on 30 June 2022 and Debian 10’s on 30 June 2024. Use it only to keep a legacy server running. For a current PHP version, see How to install PHP on Debian.

The repository steps no longer work as written. As of September 2026, the Sury repository at packages.sury.org only serves Debian 11, 12 and 13, and its FAQ says packages for Debian 9 and 10 are only available from the paid PHP LTS by Freexian service. On Debian 9 or 10, apt update reports an error for the repository line below. The steps are kept as a record of how the upgrade was done.

Method 1: upgrade from PHP 7.0 to 7.4 with Apache

Step 1. Check PHP version

Code
php -v

The output on a Debian 9 server with its default PHP 7.0:

Code
PHP 7.0.33-0+deb9u8 (cli) (built: Jul 5 2020 06:34:50) ( NTS ) 
Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies 
with Zend OPcache v7.0.33-0+deb9u8, Copyright (c) 1999-2017, by Zend Technologies

Step 2. Update System

Shell
apt update && apt upgrade

Maybe you will also need to reboot Debian.

Step 3. Configure PHP 7.4 Repository

Install the packages apt needs for an HTTPS repository and download the repository’s signing key. This was the method in 2020; the repository now installs its key with a keyring package, as the current guide shows.

Shell
sudo apt -y install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Finally, use this command to add the repository

JavaScript
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Next, update system

Shell
apt update

Step 4. Install PHP 7.4 on Debian 9/10

With the repository added, install PHP 7.4:

Shell
sudo apt install php7.4

Now run php -v again. It should report PHP 7.4.

Step 5. Install PHP modules

Shell
apt install -y php7.4-common php7.4-xml php7.4-mysql php7.4-pdo php7.4-phar php7.4-simplexml php7.4-curl php7.4-mbstring php7.4-imagick php7.4-zip php7.4-gd

Step 6. Disable PHP 7.0 module and Enable PHP 7.4 module

This switches Apache’s PHP module (mod_php) from 7.0 to 7.4. On Debian 10, disable php7.3 instead, the version Debian 10 shipped.

Shell
sudo a2dismod php7.0
sudo a2enmod php7.4
sudo systemctl restart apache2

Now log in to WordPress again: the dashboard should report PHP 7.4. WordPress may still suggest an update, because PHP 7.4 is past end of life as well.

Method 2: install PHP 7.4 with more extensions, and switch to Nginx

Step 1: Update system
Ensure your system is updated:

Shell
sudo apt update
sudo apt upgrade -y && sudo reboot

Step 2: Add the Sury PHP repository
First download the repository’s GPG key, then add the repository to a file in /etc/apt/sources.list.d/.

Shell
sudo apt -y install lsb-release apt-transport-https ca-certificates 
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Then add the repository.

JavaScript
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Step 3: Install PHP 7.4 on Debian 10 / Debian 9
Update the package lists so apt sees the new repository:

Shell
sudo apt update

Then install PHP 7.4 on Debian 10 / Debian 9:

Shell
sudo apt -y install php7.4

The -y option answers yes to apt’s confirmation prompt for you.

Install additional packages, such as the SOAP extension covered in enabling PHP SOAP on Debian. Replace xxx with the extension name:

Shell
sudo apt-get install php7.4-xxx

Or install several at once, for example:

Shell
sudo apt-get install php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}

With Apache’s PHP module, PHP 7.4’s settings are in /etc/php/7.4/apache2/php.ini (see editing php.ini over SSH).

Using PHP with Nginx

These commands stop and disable Apache, then install Nginx and PHP-FPM 7.4:

Shell
sudo systemctl disable --now apache2
sudo apt-get install nginx php7.4-fpm

Without a control panel, point your Nginx site at the PHP 7.4 socket, /run/php/php7.4-fpm.sock, the same way the current guide shows for newer versions.

If the server is managed with VestaCP, choose the PHP-FPM-74 web template in the site’s settings instead:

VestaCP site settings with the Web Template (APACHE2) field set to PHP-FPM-74

VestaCP isn’t a good choice for setting up a server today. Its GitHub repository still gets occasional commits, but its last tagged release, 1.0.0-5, is from November 2021, and its Debian installer only has configurations for Debian 7, 8 and 9. Hestia Control Panel, which is based on VestaCP, is actively developed and lists Debian 11, 12 and 13 as supported.

Main article: How to Update to PHP 7.4 for WordPress Site on Debian 9/10 on Manjaro dot site (an archived copy: the original domain no longer hosts it)

Also based on: Upgrade PHP version to PHP 7.4 on Ubuntu on Cloudbooklet

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More