Steps to install PHP 8 on the Debian server
Let’s test various web applications by installing PHP 8.0 on a Linux Debian 10 Buster or Debian 11 Bullseye server using the command line terminal …
PHP is a widely used server-side programming language, which means that it can perform actions on servers such as establishing connections to a database, generating dynamic web pages on user requests, or deleting user requests. files on the server.
It is open-source and distributed as free software. Today the abbreviation PHP stands for HyperText Process, however, it was originally known as Personal Home Page Tools. Programs encoded with this scripting language are stored as simple text files which are then converted into machine code by the web server when called. Thus, PHP programs are largely platform independent and can be run on different hardware systems.
Embedded in HTML files, PHP code supplemented static websites with dynamic information such as date and time or, for example, mixed in user input from purchase orders in confirmation pages of ordered.
How to install PHP 8 on Debian 10 or 11 Linux Server
The steps given here will work for all current active Debian Linux workstations and servers, including other distributions based on this one.
1. Add the Sury PHP repository on Debian
Where for Ubuntu, to get the latest PHP packages we need to add the Ondrej PPA repository, on Debian we use Sury – the main PHP repository for Debian. So, we add it first, then we go a step 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 the GPG key for the PHP repository
However, as we are on the verge of getting PHP packages from a newly added repository, the system needs to ensure that these come from the correct, genuine source without any modification.
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 the system update command
After completing the above two steps, it’s time to rebuild the system repository cache, so that it can recognize the packages available in the new Surg repository.
4. Command to install PHP 8 on Debian 10/11 Linux
Well our system is ready to download the packages for installing PHP 8 on our Debian server or desktop, so run:
sudo apt install php8.0
5. Installation of extensions
As we know, many functions are performed between web application and PHP using extensions, for example, to connect a database, we need PHP Mysql extension. Here are some common examples 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 verification
To confirm the installed version of PHP on Debian type-