Skip to content

Installing PHP 7.4 on Debian 11/10/9

Tutorials & Guides  ·  Christopher Sakel  ·   ·  Updated on  ·  1 min Reading time

In this blog post I want to show you how to install PHP 7.4 on Debian 9/10/11.

First we log in to the server via SSH, for example with Putty.
Now we run the following command:

  1. Update the server:
    root@testserver ~ # apt update
  2. Install required packages:
    root@testserver ~ # apt install sudo -y
  3. Download and add the public key for the repository:
    root@testserver ~ # sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
  4. Add the repository:
    root@testserver ~ # echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
  5. Update the server:
    root@testserver ~ # apt update
  6. Install PHP 7.4:
    root@testserver ~ # apt install php7.4 -y

Now we can check the PHP version with the following command:

root@testserver:~# php -v
PHP 7.4.13 (cli) (built: Nov 30 2020 20:40:09) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies


Frequently asked questions

Which Debian versions does this guide cover?
Debian 9, 10, and 11.
How do I check that PHP 7.4 installed correctly?
Run "php -v" — it should report PHP 7.4.13 (cli) with Zend Engine v3.4.0 and Zend OPcache v7.4.13.
Why do I need to add the Sury repository?
Debian's default repositories don't ship PHP 7.4, so you add the packages.sury.org repository and its public key before installing it with apt.