Tech News

How to Install PHP 8 on Debian 10

PHP is a scripting language and a powerful tool for developing dynamic and interactive web pages. It was originally created in 1994 by Danish-Canadian programmer Rasmus Lerdorf. According to data from W3Techs, PHP is used by 78.9% of websites running on the public network. So almost 8 out of 10 websites on the internet use PHP in some way.

PHP 8.0 is the latest version available for web development. This is the most advanced and secure version released by the PHP team.

This tutorial will help you install PHP 8.0 on Debain 10 Buster Linux system.

Step 1: Configure the Apt repository

Ondrej Sury maintains the PPA which contains the latest PHP packages for Debian systems.

Let’s start by installing some required packages on your system. Open a terminal and run the following commands:

sudo apt update
sudo apt install -y gnupg2 ca-certificates apt-transport-https software-properties-common

Then add the GPG key to your system to verify the packages before installation.

wget -qO -  | sudo apt-key add -

Create a PPA file on your system with the php repository on your Buster Linux system.

echo "deb  buster main" | sudo tee /etc/apt/sources.list.d/php.list

Step 2: Install PHP 8 on Debian

Your system is ready for installing PHP. Use the following commands to install PHP 8 on the Debian system.

sudo apt update
sudo apt install php8.0

La première commande mettra à jour le cache apt sur votre système et la deuxième commande installera les packages PHP.

Une fois l’installation terminée, vérifier la version de PHP sur le terminal.

php -v

Check PHP version

Step 3: Install PHP extensions

PHP comes with several extensions (also called modules) to perform specific tasks. You can install these extensions on your system as per your requirement.

First, search for available modules in the repository:

sudo apt search php8.0-*

Then install the required php modules on your system. The following command will install some frequently used PHP modules on your system.

sudo apt install php8.0-{mysql,imap,ldap,xml,curl,mbstring,zip}

You can check the currently installed and activate PHP modules on your system by running the following command.

php -m

Step 4Configure Apache with PHP

Generally, the above commands also install the Apache PHP extension on your system. But if it is not installed then run below command to install Apache with PHP 8 module.

sudo apt install apache2 libapache2-mod-php8.0

After successful installation, restart the Apache service to reload the newly installed modules.

sudo systemctl restart apache2

Next, check that the PHP modules are loaded with Apache. Create a php script with a phpinfo()function under the default document root.

echo "<?php phpinfo(); ?>" > /var/www/html/info.php

Access this file in the browser using the server’s IP address. For example: http://server-ip/info.php

PHP 8 on Debian 10

You will see the detailed PHP information on the webpage.

If you have any questions or suggestions, let us know in the comments. Also consult this guide if you want to learn how to install and secure MariaDB on a Debian 10 server.

Related Articles

Leave a Reply

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

Back to top button