Hamsa K
Editor
5 min read | 3 years ago

How to Install php 8 on Debian 10

How to Install php 8 on debian 10 system

PHP is a general-purpose scripting language especially suited to web development and used for creating dynamic and interactive Web pages.PHP 8.0 is the latest major release and includes performance improvements, and lots of new features such as named arguments, JIT compiler, union types, match expression,variable syntax tweaks etc.

In this article, we will show you how to install PHP 8 on Debian 10 system.

Step 1: install packages

install all packages using apt to make sure your system is uptodate.

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

Also Read -> How to Install PHP 8 on Ubuntu 20 04

Step 2: setup apt repo

To install php, we need to add  sury php ppa repository. Before adding this we need to add the GPG key to your system to verify the packages.

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

Add sury php ppa repository with the following command.

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

Step 3: install Php 8

once Sury repo is added, update the repository metadata and install php8.

sudo apt update 
sudo apt install php8.0 php8.0-cli php8.0-common

To verify php version, use php command.

php -v

sample output:

PHP 8.0.3 (cli) (built: Mar  5 2021 08:38:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies


Also Read -> How to Install PHP 8 on Centos 8

Step 4: Install php extensions

you can install required php modules with the following command.

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

Also you can check for currently installed and active PHP modules

php -m

you can setup apache with php8 with the following command.

sudo apt install apache2 libapache2-mod-php8.0 

then restart apache service as below

sudo systemctl restart apache2
sudo systemctl status apache2

Step 5: Test php

now you can create a php script with phpinfo() function under the default document root to verify the php modules with apache.

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

then open your favorite browser and type http://ip_address/phpinfo.php

Also Read -> How to Install PHP 7.4 on Centos 8



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy