How to Install PHP 8 on Debian 10
Abstract: ~$ sudo apt install php8.0 -y To Install PHP 8 FPM for NGINX Web server~$ sudo apt install php8.0-fpm -y To install PHP extensions
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 commandLogin 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
[email protected]:~$ sudo apt update [email protected]:~$ sudo apt upgrade -y
Once all the updates are installed successfully and then reboot your system using below reboot command,
[email protected]:~$ sudo rebootStep 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
[email protected]:~$ sudo apt install -y lsb-release apt-transport-https ca-certificates wget [email protected]:~$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg [email protected]:~$ 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.
[email protected]:~$ 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 commandTo install php 8 for apache web server and other web applications, run the following command
[email protected]:~$ sudo apt install php8.0 -y
To Install PHP 8 FPM for NGINX Web server, run the following command
[email protected]:~$ 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
[email protected]:~$ sudo apt install -y php8.0-{mysql,cli,common,snmp,ldap,curl,mbstring,zip} -y
To Verify the PHP version, execute below php command,
[email protected]:~$ 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 [email protected]:~$
To list all the loaded PHP modules, run beneath php command,
[email protected]:~$ php -mStep 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
[email protected]:~$ 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
[email protected]:~$ 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
[email protected]:~$ sudo systemctl restart php8.0-fpmStep 5) Test PHP 8 via Web Browser
Let’s create info.php file under apache web server document root,
[email protected]:~$ sudo vi /var/www/html/info.php <?php phpinfo(); ?>
Save & exit the file and restart apache service using the following systemctl command
[email protected]:~$ 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.