Let’s test various web applications by installing PHP 8.0 on Debian 10 Buster or Debian 11 Bullseye Linux server using command line terminal…
PHP is a widely used server-side programming language that means it can perform actions on servers such as establishing connections to a database, generate dynamic webpages on user requests, or delete files on the server.
It is open-source and distributed as free software. Today, the abbreviation PHP stands for HyperText Process, however, originally it was known as Personal Home Page Tools. The programs coded with this scripting language stored as simple text files which later converted into machine code by the web server when they are called up. Thus, PHP programs are largely platform-independent and can be executed on different hardware systems.
Embedded in HTML files, the PHP code supplemented static websites with dynamic information such as date and time or, for example, mixed in the input of users from order forms in order confirmation pages.
How to install PHP 8 on Debian 10 or 11 Linux Server
The steps given here will work for all current active Debian Linux desktop and server including other distros based on it.
1. Add Sury PHP repo on Debian
Where for Ubuntu, to get the latest PHP packages we need to add the Ondrej PPA repo, on Debian we use Sury- the main PHP repository for Debian. Thus, first we add it and then move further to perform other steps.
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
2. Import GPG Key for PHP repo
As we are about to get PHP packages from a newly added repo, however, the system needs to make sure that these are from the right and genuine source without any alterations.
sudo apt install wget sudo apt install apt-transport-https software-properties-common
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
3. Run system update command
Once the above two steps have been completed, it’s time to rebuild the system repository cache, so it could recognize the available packages in the newly added Surg repo.
sudo apt update
4. Command to install PHP 8 on Debian 10/11 Linux
Well, our system is ready to download the packages for the installation of PHP 8 on our Debian server or desktop, therefore run:
sudo apt install php8.0
5. Extensions installation
As we know there are lots of functions performed between a web application and PHP with the help of extensions, for example, to connect a database, we need to have a PHP Mysql extension. Here are some common ones to install.
sudo apt install php8.0-common php8.0-gd php8.0-ldap php8.0-odbc php8.0-xsl php8.0-apcu php8.0-curl php8.0-gmp php8.0-opcache php8.0-mbstring php8.0-pgsql php8.0-imagick php8.0-memcached php8.0-bz2 php8.0-ds php8.0-imap php8.0-cgi php8.0-mysql php8.0-cli php8.0-fpm php8.0-xml
6. Check Verison
To confirm the installed version of PHP on Debian type-
- How to install PHP 8 on Ubuntu 20.04 LTS Server
- How to install & configure Lighttpd web server on Ubuntu 20.04 LTS
- Install XAMPP on Ubuntu 20.04 LTS