The following tutorial guides you step by step through the process of installing PHP 8.0 on Debian 10. PHP is an open-source general-purpose scripting language, mostly used by web developers as it can be easily be embedded into HTML.
PHP version 8.0 was officially released on November 26, 2020, and it is the latest release of the PHP language. It is packed with lots of new improvements, features, and optimizations including named arguments, attributes, constructor property promotion, JIT (Just in Time Compiler), match expression, union types, null safe operator, better error handling, improvements in the type system, and consistency. Also, according to multiple tests, PHP 8.0 can handle much more requests per second, compared to the older versions of PHP, so if your PHP-based website or application is fully compatible with PHP 8.0, you should definitely consider upgrading to the latest version.
- VPS running with Debian 10. We will use one of our VPS hosting plans
- SSH access
- System user with sudo or root privileges
Login and Update the server
In order to start with the installation of PHP 8.0 on our Debian 10, we have to access the server via SSH. We will log in as user root, but you can use any system user which has sudo privileges:
ssh [email protected]_Address -p Port_number
IP_Address and Port_number should be replaced with the actual IP address and SSH port number.
Once the SSH connection is established and you are in, in order to have the latest bug fixes, new features, and security fixes of all installed packages, it is always a good idea to update the installed packages on the server.
apt update && apt upgrade
Add third party APT repository
Debian 10 by default has PHP 7.3 in its repositories. To check what PHP version is available in the Debian repositories run the following command:
apt-cache policy php
php:<br>Installed: 2:7.3+69<br>Candidate: 2:7.3+69<br>Version table:<br>*** 2:7.3+69 500<br>500 http://httpredir.debian.org/debian buster/main amd64 Packages<br>100 /var/lib/dpkg/status
Or if PHP is already installed on the VPS, check the installed version
PHP 7.3.27-1~deb10u1 (cli) (built: Feb 13 2021 16:31:40) ( NTS )<br>Copyright (c) 1997-2018 The PHP Group<br>Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies<br>with Zend OPcache v7.3.27-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
From the output above we can see that we can only install PHP 7.3 from the official Debian repositories, so if need the latest PHP 8.0 version, we will have to add a third-party repository. But first, let’s install some necessary packages
apt -y install apt-transport-https software-properties-common gnupg2
Once the packages are installed, download the GPG key and add it to your server to verify the necessary PHP packages
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
Create a Personal Package Archives (PPAs) file with the new PHP repository
echo "deb https://packages.sury.org/php/ buster main" | sudo tee /etc/apt/sources.list.d/php.list
And finally, update the repositories and install PHP 8.
apt update && apt install php8.0
Once all dependencies are installed, check the version of PHP installed on your Debian 10 server, to confirm that PHP 8 is successfully installed
PHP 8.0.9 (cli) (built: Jul 30 2021 13:09:07) ( NTS )<br>Copyright (c) The PHP Group<br>Zend Engine v4.0.9, Copyright (c) Zend Technologies<br>with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
Install PHP 8 extensions
In order to enable some extra features, functionalities, or libraries PHP has lots of additional extensions. To check the list of all available extensions for PHP 8.0, execute the following command
apt search php8.0-*
… php8.0-maxminddb/buster 1.10.1-1+0~20210802.2+debian10~1.gbp162f0b amd64 Reader for the MaxMind DB file format for PHP php8.0-maxminddb-dbgsym/buster 1.10.1-1+0~20210802.2+debian10~1.gbp162f0b amd64 debug symbols for php8.0-maxminddb php8.0-mbstring/buster 8.0.9-1+0~20210730.22+debian10~1.gbp99e7e9 amd64 MBSTRING module for PHP php8.0-mbstring-dbgsym/buster 8.0.9-1+0~20210730.22+debian10~1.gbp99e7e9 amd64 debug symbols for php8.0-mbstring php8.0-mcrypt/buster 3:1.0.4-5+0~20210223.3+debian10~1.gbp68347e amd64 PHP bindings for the libmcrypt library …
If for some reason you need to install the PHP mbstring extension, you can easily do it with the following command
apt -y install php8.0-mbstring
That’s all. If you closely followed the tutorial, you have successfully installed PHP 8 on your Debian 10 VPS from a third-party repository. If you need more specific details about this major update of PHP, you can check their release notes or their documentation.
Of course, you don’t need to install PHP 8.0 on Debian 10 yourself if you use one of our Debian Hosting or any Linux VPS hosting plans, in which case you can simply ask our expert Linux admins to install and set this up for you. They are available 24/7 and will take care of your request immediately.
PS. If you liked this post on how to install PHP 8.0 on Debian 10, please share it with your friends on the social networks by using the share shortcuts below, or simply leave a comment in the comments section. Thanks.