How To Install PHP on Debian 11

Web application development is the order of the day. This is demonstrated by the large number of tools that exist for this purpose. One of the programming languages used for this is the powerful PHP. So, in this post, you will learn how to install PHP on Debian 11 which we already know how used it is.

Introducing to PHP

PHP is a programming language for developing applications and creating dynamic websites, i.e. websites that process user data. This programming language is intended for developing web applications and creating web pages, favoring the connection between the servers and the user interface.

The best thing about using PHP is that it is extremely simple for the beginner, but at the same time, it offers many advanced features for professional and more advanced programmers. For example, with PHP you can process forms, generate pages with dynamic content, or send and receive cookies, among many other things.

Some of the advantages of PHP are:

  • It is an open-source language, which can be easily edited by any developer or programmer. It is also adaptable to many web projects.
  • Also, it has a very clean syntax similar to Java or C++, so the learning curve is eaysier than other programming languages.
  • It allows you to create work environments easily.
  • PHP is very simple to install and is compatible with many operating systems.
  • It integrates in a very simple way in the database. In addition, it supports many database drivers including the popular MariaDB, MySQL, PostgreSQL, and SQLite.

Another reason PHP has become so popular is the large number of tools associated with it. An example of this is Composer’s dependency manager; or a large number of PHP frameworks available.

As PHP runs server-side and many servers run on Linux, PHP’s support for this system is total. So, we can install it on Debian 11 very easily and naturally.

Install PHP on Debian 11

PHP is available for almost all Linux operating systems and distributions. Therefore, it is included in the official Debian 11 repositories.

So, open a terminal and you can search for all PHP related packages as follows

sudo apt update
sudo apt search php

You will get a very long screen output due to a large number of PHP packages.

But to install PHP, you have to execute the following command

sudo apt install php

For Debian 11, we can also use the command

sudo apt install php7.4

This will install PHP along with other dependencies but since it is a very lightweight language, the installation will take very little time.

As PHP is a language that has many extensions that are dependencies of different web applications, then you can install it in the following way

sudo apt install php7.4-[extension]

And so you can do with the most popular extensions like imap, intl, json, mbstring and many more.

Install the latest version of PHP on Debian 11

Debian 11 includes PHP 7.4 which is a modern version of PHP but not the latest. So if you are developing an application and you consider it best to use the latest stable version which is 8.0 then follow these instructions.

First, we have to make sure that PHP is not installed on the system because there may be compatibility issues. After that, install some necessary packages.

sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https

Add the GPG key of the repository we will add.

wget -qO - | sudo apt-key add -

Then add the Sury repository which contains packages for many PHP versions and their respective modules.

sudo sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Refresh APT and finally install PHP 8 which is the latest stable version of PHP.

sudo apt update 
sudo apt install php8.0

You can also install the PHP extensions.

sudo apt install php8.0-[extension]


PHP is a popular programming language that owes its fame to the large number of web applications that are currently being developed. In addition to this, it is an easy language to learn and understand.

So, tell us, do you like PHP? Will you learn it? leave us a comment and buy our post.

Scroll to Top