×


Install PHP 8.0 on Debian / Linux Mint - Step by Step Process ?

Originally developed by Rasmus Lerdorf, a Danish-Canadian developer, PHP is a server-side scripting language that is geared towards the development of both dynamic and static webpages. PHP is a recursive acronym for PHP Hypertext Preprocessor but was initially an acronym for Personal Home Page. Currently, two PHP releases are receiving active support – PHP 7.4 and PHP 8.0.

The most current and stable release is PHP 8.0. It was released on Nov 16, 2020, and enjoys support until 2023provides improvements and enhancements such as named arguments, null safe operator, union types, JIT (Just In Type) compiler, and improvements in consistency and error-handling.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related PHP Installation and configuration queries on any Linux Distribution.

In this context, we shall look into the installation procedure of PHP 8.0 on Debian / Linux Mint.


Steps to Install PHP 8.0 on Linux Mint / Debian / Ubuntu

1. Update the system

To begin, we are going to update the package list of the system. This can be done by executing the command:

$ sudo apt update

Once updated, install the dependencies required:

$ sudo apt install software-properties-common ca-certificates lsb_release apt-transport-https


2. Enable the Sury APT repository

Here, add the SURY repository to our system. SURY is a third-party PHP repository that packages PHP packages for Debian. To add the repository, run the command:

$ sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Next, import the repository's GPG key:

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


3. Install PHP 8.0

To install PHP 8.0, update the package lists to sync with the newly added SURY repository

$ sudo apt update

Then install PHP 8.0 on Debian Buster as follows.

$ sudo apt install php8.0

Once installed, verify the PHP release installed:

$ php -v

Also, you can install PHP extensions using the syntax:

$ sudo apt install php-extension

If you are installing multiple extensions, specify them inside the curly braces as shown below. Here, we are installing the php-cli, php-mbstring, php-xml, php-common, php-ldap the php-curl extensions:

$ sudo apt install php8.0-{cli,mbstring,xml,common,ldap,curl}


[Need help in Configuring PHP on Ubuntu Linux ? We can help you. ]


Conclusion

This article covers how to install PHP 8.0 on Debian 10. To verify the installed version of PHP, use the php command below:

$ php -v


How to install PHP 7.x extensions ?

The following syntax is used to install PHP 7.x extensions:

$ sudo apt-get install php7.x-extension

or

$ sudo apt-get install php-extension


To install the most commonly used PHP 7.x extensions by running the command in the terminal:

for PHP 7.4,

$ sudo apt-get install php7.4-mysql php7.4-mbstring php7.4-xml php7.4-bcmath php7.4-curl php7.4-gd php7.4-zip

for PHP 7.3,

$ sudo apt-get install php7.3-mysql php7.3-mbstring php7.3-xml php7.3-bcmath php7.3-curl php7.3-gd php7.3-zip

for PHP 7.2,

$ sudo apt-get install php7.2-mysql php7.2-mbstring php7.2-xml php7.2-bcmath php7.2-curl php7.2-gd php7.2-zip

for PHP 7.1,

$ sudo apt-get install php7.1-mysql php7.1-mbstring php7.1-xml php7.1-bcmath php7.1-curl php7.1-gd php7.1-zip

for PHP 7.0,

$ sudo apt-get install php7.0-mysql php7.0-mbstring php7.0-xml php7.0-bcmath php7.0-curl php7.0-gd php7.0-zip