PHP abbreviated as “HyperText Processor”, is the open-source programming language used for Web application development. It is a scripting language, mostly used for the front end with HTML. It can be used to create e-commerce websites, manage databases, and do session monitoring.
It is available for all OS. The latest version of PHP is version 8 and in this article, we will discuss the installation of PHP on the Debian 11 Bullseye Linux system.
Follow the steps below for successful installation of PHP on your Debian System:
First, update all the packages of the system by below-mentioned command:
sudo apt update
After updating packages, now install the dependencies required by the below-mentioned command:
sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https
Step 1 – Enabling SURY Repository
The following step is to integrate the SURY repository into our system. SURY is a Debian-based third-party PHP repository that bundles PHP software, run the following command to add SURY repository:
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
Importing the GPG key for the repository by the below-mentioned command:
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
Step 2 – Installing PHP on Debian 11
Now again update packages for syncing them with the recently added SURY repository before installing php:
sudo apt update
The SURY repository contains PHP 8.0, 7.4, 7.3, 7.2. 7.1, 7.0 & PHP 5.6. As the latest stable version of PHP is 8.0, but a large number of websites still required PHP 7. This repository also includes packages of PHP 8.1 that is currently in beta. You can install any of the required PHP versions on your system.
Run the following command to install PHP 8 on Debian 11:
sudo apt install php8.0
To install any other version change replace
8.8 with the version you want to install. You can also install multiple versions on a single system.
Step 3 – Installing PHP Extension
Moreover, we can also add the php extension by below-mentioned syntax:
sudo apt install php8.0-[extension]
Replace [extension] with the extension you want to install, if you want to add multiple extensions then include them in braces, I am going to install “php-mbstring, php-cli, php-xml, php-common, and php-curl” by running the below-mentioned command:
sudo apt install php8.0-cli php8.0-mbstring php8.0-xml php8.0-common php8.0-curl
Users have installed different PHP version, need to replace
8.0 with requred PHP version.
Step 4 – Checking PHP Version
Now after installation verify that the correct version of PHP is installed by checking the version number by the below-mentioned command:
Output:PHP 8.0.10 (cli) (built: Aug 26 2021 16:06:19) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.10, Copyright (c) Zend Technologies with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies
PHP is a free, server-side programming language also used with HTML programming language for creating dynamic websites. It is available for all operating systems but in this article, we discuss its installation on Debian 11 (Linux OS) Bullseye. You will successfully install PHP on Debian 11 after going through this guide.