Easy way to Install PHP 8.0 on Debian 11 Bullseye Server

A quick guide for installing PHP 8.0 on Debian 11, 10, and 9 Servers to install various web applications or CMS based on this server-side scripting language.

Php 8.0 is the latest stable version of this programming language to use for commercial purposes. It is a server-side language, this means that the language can only perform actions on the server: For example, it can establish connections to a database or delete files on the server. You can easily convert an HTML file into PHP. To do this, you simply have to save the HTML file under .php. You can upload this PHP file to your server and call it up – without the actual PHP code. The output is unchanged.

PHP is a cross-platform language hence can be executed on all popular operating systems. If you want to use PHP 8.0.x for your web application installed on Debian Linux then here is the tutorial to follow.

You can also look at our previous articles 

 

PHP 8.0 Installation on Debian 11 Bullseye Server

The below-given steps can be used for the previous versions of Debian such as 10 Buster and 9 Stretch.

Step 1: Add Sury PHP repo

The packages to install PHP 8.0 on Debian 11 are not available in the default base repository, hence we have to add the SURY repository manually.

The below given is a single command, copy and paste it in your terminal. And hit the Enter key.

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main"\
 | sudo tee /etc/apt/sources.list.d/sury-php.list

 

Step 2: Import GPG Key on Debian

Next, the system needs to verify the packages we receive to install PHP 8.0 from the Sury repository, to confirm they have not been altered by anyone.

wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -

 

Step 3: Run system update

Now, run the system update command that will flush and rebuild the repository cache and help the system to recognize the newly added repo and its packages.

sudo apt update

 

Step 4: Command to install Php 8.0 on Debian 11, 10 & 9

Once the GPG and Repo have been configured, we can use the default Debian APT package manager to install PHP 8.0 on the system.

sudo apt install php8.0

install Php 8.0 on Debian 11 10 9

 

Step 5: PHP 8.0 Extensions installation command for Debian 11/10/9

PHP 8.0 is on your system, we can go for the installation of the required extensions as per your web application requirements.

the syntax is

sudo apt install php8.0-{module-names}

For example, you want to install bcmath, curl, zip, soap, opcache,xml,fpm,curl,mbstring extensions, then simply replace the module-names in the above-given syntax with the extensions you want to install separated by a comma.

Let’s say you want to install  bcmath,curl,zip,soap,opcache,xml,fpm,curl,mbstring the above syntax will be like this:

sudo apt install php8.0-{bcmath,curl,zip,soap,opcache,xml,fpm,curl,mbstring}

 

Check Loaded PHP Modules

If you want to know what are the modules are installed and activated for your current PHP to use for various web applications, simply type:

php -m

This will list all the loaded php Extensions.

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.