The stable version of PHP 8 has been released for a long time, and this version has many advanced features and improvements. In this guide, we will demonstrate step by step how to install PHP 8 on a Debian 10 system.
System Requirements
- Debian 10 Installed system
- Local user with sudo rights
- Internet connection
Let's go to the php8 installation steps on Debian 10 system
1) Install updates using the apt command
Log in to the Debian 10 system as a local user and install all available updates using the apt command
sysadmin@debian-10:~$ sudo apt update
sysadmin@debian-10:~$ sudo apt upgrade -y
After installing the update, restart the system
sysadmin@debian-10:~$ sudo reboot
2) Enable PHP 8 repository (SURY PPA)
PHP 8 packages are not available in the default Debian 10 package repositories. So we have to enable SURY PPA, run the following command:
sysadmin@debian-10:~$ sudo apt install -y lsb-release apt-transport-https ca-certificates wget
sysadmin@debian-10:~$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sysadmin@debian-10:~$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
update package index
sysadmin@debian-10:~$ sudo apt update
3) Install PHP 8 using the apt command
Install php 8 for Apache web server
sysadmin@debian-10:~$ sudo apt install php8.0 -y
Install php8 FPM for NGINX web server
sysadmin@debian-10:~$ sudo apt install php8.0-fpm -y
To install the PHP extension, run the following command
$ sudo apt install php8.0-{extensions-name}
Suppose to install extensions like: mysql, cli, common, snmp, ldap, curl, mbstring, zip
sysadmin@debian-10:~$ sudo apt install -y php8.0-{mysql,cli,common,snmp,ldap,curl,mbstring,zip} -y
Check PHP version
sysadmin@debian-10:~$ php -v
PHP 8.0.0 (cli) (built: Dec 6 2020 06:56:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies
sysadmin@debian-10:~$
View all loaded PHP modules
sysadmin@debian-10:~$ php -m
4) Configure PHP
To configure PHP 8 for the Apache web server, edit its configuration file /etc/php/8.0/apache2/php.ini, adding or changing the following parameters
sysadmin@debian-10:~$ sudo vi /etc/php/8.0/apache2/php.ini
--------
upload_max_filesize = 16M
post_max_size = 30M
memory_limit = 128M
max_execution_time = 500
max_input_vars = 2000
max_input_time = 1000
--------
Save and close the file, restart the Apache service
sysadmin@debian-10:~$ sudo systemctl restart apache2
To configure PHP 8 for the Nginx web server, edit its configuration file /etc/php/8.0/fpm/pool.d/www.conf
sysadmin@debian-10:~$ sudo vi /etc/php/8.0/apache2/php.ini
Save and close the file, restart the Nginx service
sysadmin@debian-10:~$ sudo systemctl restart php8.0-fpm
5) Test
Let us create info.php file in apache web server document root directory
sysadmin@debian-10:~$ sudo vi /var/www/html/info.php
<?php
phpinfo();
?>
Save and exit the file, and restart the apache service
sysadmin@debian-10:~$ sudo systemctl restart apache2
Now open a web browser and enter the following URL
http://{Your-Server-IPAddress}/info.php