Recently stable version of PHP 8 has been released. This version comes with lot of advance features and improvements. In this guide, we will demonstrate on how to install PHP 8 on a Debian 10 system step by step.
Minimum requirements for PHP 8:
- Debian 10 Installed system
- Local user with sudo rights
- Internet connection
Let’s jump into PHP 8 installation steps on Debian 10 system,
Step 1) Install updates with apt command
Login to your Debian 10 system with the local user and install all available updates using apt commands,
Note: In case you don’t want to install updates then you skip this step and then move to step 2
sysadmin@debian-10:~$ sudo apt update sysadmin@debian-10:~$ sudo apt upgrade -y
Once all the updates are installed successfully and then reboot your system using below reboot command,
sysadmin@debian-10:~$ sudo reboot
Step 2) Enable PHP 8 Repository (SURY PPA)
PHP 8 packages are not available in the default Debian 10 package repositories. So, to install php 8 first we have to enable SURY PPA,
Run the Following commands one after the another
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
Run below ‘apt update’ command after enabling SURY PPA repository to update package index.
sysadmin@debian-10:~$ sudo apt update
Above output confirms that we are ready to install php 8 on Debian 10 system,
Step 3) Install PHP 8 using apt command
To install php 8 for apache web server and other web applications, run the following command
sysadmin@debian-10:~$ sudo apt install php8.0 -y
To Install PHP 8 FPM for NGINX Web server, run the following command
sysadmin@debian-10:~$ sudo apt install php8.0-fpm -y
To install PHP extensions, run the following
$ sudo apt install php8.0-{extensions-name}
Let’s assume we want to install php extensions like mysql, cli, common, snmp, ldap, curl, mbstring and zip
sysadmin@debian-10:~$ sudo apt install -y php8.0-{mysql,cli,common,snmp,ldap,curl,mbstring,zip} -y
To Verify the PHP version, execute below php command,
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:~$
To list all the loaded PHP modules, run beneath php command,
sysadmin@debian-10:~$ php -m
Step 4) Configure PHP 8 for Web Applications
To configure PHP 8 for the web applications like apache web server, edit its configuration file ‘/etc/php/8.0/apache2/php.ini’, add or change the below parameters that suits to your application
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 & close the file. To make the above changes into the effect restart the Apache service
sysadmin@debian-10:~$ sudo systemctl restart apache2
To configure php 8 fpm for NGINX web server, edit its configuration file ‘/etc/php/8.0/fpm/pool.d/www.conf‘ and set the parameters that suits to your nginx server setup. After making the changes to file, don’t forget to restart php 8 fpm service
sysadmin@debian-10:~$ sudo systemctl restart php8.0-fpm
Step 5) Test PHP 8 via Web Browser
Let’s create info.php file under apache web server document root,
sysadmin@debian-10:~$ sudo vi /var/www/html/info.php <?php phpinfo(); ?>
Save & exit the file and restart apache service using the following systemctl command
sysadmin@debian-10:~$ sudo systemctl restart apache2
Now open the Web browser and type the following URL:
http://<Your-Server-IPAddress>/info.php
Perfect, above screen confirms that PHP 8 has been installed successfully on Debian 10 system. That’s all from this guide, please don’t hesitate to share your feedback and comments in the comments section below.
The post How to Install PHP 8 on Debian 10 first appeared on LinuxTechi.