Pentarock Technologies

SHARING KNOWLEDGE

How to Install PHP 8.0 on Debian 10 Buster

5 min read
How to Install PHP 8 on Debian 10

In this guide we will see how to install PHP 8.0 on Debian 10 Buster. PHP is an open source server side programming language. However, I will try to cover all the related topics like installation of all the most common PHP 8.0 extensions etc. PHP is also known as a server side scripting language. Moreover, it is one of the most widely used languages for development of dynamic and interactive web pages. As we know that the first step in programming is getting our system up and running with our favorite programming language installed and configured on it. Normally PHP is used with MySQL or MariaDB Database Server at the backend.

However, in this tutorial we will install and setup PHP 8.0 programming environment. Additionally, we will also test this programming environment.

Link to The Official Website of PHP

Prerequisites for Installation of PHP 8.0 on Debian 10 Buster

Following are the point wise basic requirements for installing PHP 8.0 on Debian 10 Buster operating system

  1. First we will require a machine with pre-installed Debian 10 Buster Server or Desktop operating system. If you want to start fresh by installing Debian 10 Buster operating system on your machine then you can follow the link to our tutorial as given below:
How to Install Debian 10 Buster
  1. Additionally, we will also require root or administrative User Name and Passwords of the installed operating system. This will enable us to install the PHP language and its associated applications, libraries and dependency software in the operating environment.
  2. Also, we will need a stable and fast internet connection for downloading and installing all the applications to setup the PHP 8 programming environment.

Update Debian 10 Buster Operating System

Next, before installing PHP 8.0 we must update the Debian 10 Buster operating system. Next, to update the operating system open the terminal window and issue the following command as given below:

sudo apt-get update
sudo apt-get upgrade
Link to The Official Website of Debian 10 Buster

Installation of PHP 8.0 on Debian 10 Buster

However, the default PHP version in Debian 10 Buster repository is PHP version 7.3. That is if we try to install PHP without specifying the version number in the command line then PHP version 7.3 will be installed on our debian 10 system.  Moreover, it is better not to depend on the default version of the PHP. Therefore, in this tutorial we will install PHP version 8.0.

Setup the apt Repository

Moreover, Ondrej Sury is maintaining the PPA that contains the latest PHP packages for the Debian Systems. Next, we will install repository. Furthermore, all the versions of PHP are maintained in this repository. Therefore, we can install any version of the PHP language of our choice from this repository.  Additionally, we will now install software-properties-common that performs management of additional software. Next, to install this issue the following command in the terminal window:

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

Further, we will get a prompt for confirmation of installation. Pres Y to proceed to install the application.

Next, We have to add the GPG key to our system to verify the packages before installation.

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

Now, we have to create a PPA file in our system with php repository on our buster Linux system. To do this issue the following command in the terminal window:

echo "deb https://packages.sury.org/php/ buster main" | sudo tee /etc/apt/sources.list.d/php.list

Again run apt update to refresh the local package manager. Issue the following command in the terminal window:

sudo apt-get update

Further, we are ready to install the PHP version of our choice. Here we have chosen to install PHP 8.0. Now issue the following command in the terminal window to install PHP 8.0.

sudo apt install php8.0

Now to verify the installed version of PHP, issue the following command in the terminal window:

sudo php -v

The output of the above command will be similar to the given below:

sudo php -v
PHP 8.0.9 (cli) (built: Jul 30 2021 13:09:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies

Install most common extensions (packages) of PHP 8.0

Finally, we have successfully installed PHP 8.0 on our machine. Now this is the time when we should install the most common PHP extensions or packages on our system. Further, we can install more than one PHP extensions just by issuing one command in the terminal window. For example to install the most common PHP packages or extensions of PHP 8.0, issue the following command:

sudo apt install php8.0-gd php8.0-xml php8.0-soap php8.0-mbstring php8.0-mysql

However, the Apache Web Server is one of the most common web servers for deploying PHP web applications. Next, to integrate PHP 8.0 with Apache Web Server we have to install the following Apache module:

sudo apt install libapache2-mod-php8.0

Furthermore, to enable the PHP 8.0 modules, issue the following command in the terminal windows:

sudo a2enmod php8.0

Then to reload the apache2 web server, issue the following command in terminal window:

sudo systemctl reload apache2

Test the PHP 8.0 Installation

Now is the time to test our PHP 8.0 installation. For this navigate to the directory ‘/var/www/html’. Next open your favorite text editor and create a file phpinfo.php. However, we are using nano editor here. Next copy and paste the lines given below in the phpinfo.php file. Then save the file and exit from the text editor.

<?php
phpinfo();
?>

Now open your favorite browser and type http://localhost/phpinfo.php and we will see the output in the browser as shown below.

phpinfo

Additionally, all the PHP configurations of Apache Web Server are normally saved in /etc/php/8.0/apache2/php.ini configuration file. From this we can get the list of all the loaded PHP extensions. To get list of all the loaded PHP extension, issue the following command in the terminal window:

sudo php –m

The output of the above command will be similar to the output given below:

sudo php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache

Ultimately we have successfully installed PHP 8.0. We have also installed the most command extensions of PHP. We have also listed the loaded extensions and checked the PHP version. Now we can start using PHP 8.0. Enjoy!

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.