In this tutorial, I will show you how to install PHP 8 on your Debian server.

Getting Started

Make sure your server is having the latest packages by running the command.

apt update && apt upgrade -y

I will use the SURY PHP PPA repository which contains all the released versions of PHP to date.

Install the below packages.

apt -y install lsb-release apt-transport-https ca-certificates wget

Download and import gpg key.

wget -O /etc/apt/trusted.gpg.d/php.gpg

Once you have downloaded the PPA you can add it to the server packages.

echo "deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Now you can proceed the installation of PHP 8 by updating the system.

apt update

Install PHP 8

apt install php8.0

Verify installation

php -v

I have apache installed on my server, so I can verify PHP 8 installation in PHP sample file.

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

Now open in browser http:/your-IP/info.php

That’s all, you have successfully installed PHP 8 on your Debian server.