Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 12 - Install PHP 8.4

The easiest way to install later versions of PHP such as PHP 8.4 is to add Ondrej's repository.

sudo apt update \
  && sudo apt install ca-certificates apt-transport-https -y \
  && sudo wget -O /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg \
  && sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" \
  > /etc/apt/sources.list.d/php.list'

Then you just need to install the PHP version you want. E.g.

sudo apt update \
  && sudo apt install php8.4-cli -y

Removing Existing PHP

If you had already installed PHP from native packages remove it before installing the later version:

sudo apt-get remove php8.2 php8.2-* -y
sudo apt autoremove -y
Last updated: 10th March 2025
First published: 30th June 2023

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch