Skip to content

How to Install PHP (8.4,7.4 & 5.6) on Debian 13

Advertisement

As of October 14, 2025, PHP version 8.4.13 is the latest version available for installation on Debian systems. In this tutorial you will learn installation process of PHP 8.4 and other PHP versions on Debian 13 Linux systems.

Step 1: Update Packages

First of all, update the apt cache and install a few required packages.

sudo apt update
sudo apt install gnupg apt-transport-https ca-certificates

Step 2: Add PHP Repository

Now add the PHP repository in your Debian system.

wget -qO - https://packages.sury.org/php/apt.gpg | sudo gpg --dearmor -o /usr/share/keyrings/sury-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/sury-archive-keyring.gpg] https://packages.sury.org/php/ bookworm main" | sudo tee /etc/apt/sources.list.d/sury-php.list

Step 3: Install PHP

After adding the required repositories, you can install php of required version. The following commands will install PHP 8.4 on your system.

sudo apt update
sudo apt install php8.4 php8.4-cli

To install a different version, just replace 8.4 with your version like 8.0 or 7.4 etc. The available versions are PHP 8.4, 8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, and PHP 5.6.

Step 4: Verify Installation

Once the installation finished, you can check active php cli version using:

php -v

Step 5: Install Extensions

You may also need to install other php modules based on your project requirements. Make sure to change PHP version as per your version.

sudo apt install php8.4-mysql php8.4-curl php8.4-xml php8.4-mbstring

Step 6: Install Apache and PHP Apache Module

If your application required a web server to serve website content, install Apache with PHP module.

sudo apt install apache2 libapache2-mod-php8.4

Step 7: Test PHP with Apache

Now create a simple phpinfo script in default document root and try to access it. If everything fine, You will see the PHP configuration details.

echo "" | sudo tee /var/www/html/info.php
curl http://localhost/info.php

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top