Debian 8 – How To Install PHP (7.2, 7.1 & 5.6) on Debian 8 Jessie

PHP 7.2 is the latest stable release available for the installation. This tutorial will help you with the installation of multiple PHP versions on your system. Now follow this tutorial to Install PHP on Debian 8 Jessie.

Prerequisites

Login to your Debian 8 system using shell access. For remote systems connect with SSH. Windows users can use Putty or other alternatives applications for SSH connection.

ssh root@debian8

Run below commands to upgrade the current packages to the latest version.

sudo apt update 
sudo apt upgrade

Enable PHP PPA on Debian 8

Let’s execute the following commands to install the required packages first on your system. Then import packages signing key. After that configure PPA for the PHP packages on your system.

sudo apt install ca-certificates apt-transport-https 
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
sudo echo "deb https://packages.sury.org/php/ jessie main" | tee /etc/apt/sources.list.d/php.list

You Debian 8 system is prepared for the PHP installation. Install the required PHP on Debian 8 system using the following options.

Installing PHP 7.2

You can also install the Latest PHP version on your system. Run the following commands to install PHP 7.2 on Debian 8.

sudo apt update
sudo apt install php7.2

Also install required php modules.

sudo apt install php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-xml

Installing PHP 7.1

If your application has the specific requirement of PHP 7.1, You can use the following commands for installing PHP 7.1 on Debian 8 Jessie.

sudo apt update
sudo apt install php7.1

Also, install the required PHP modules.

sudo apt install php7.1-cli php7.1-common php7.1-curl php7.1-gd php7.1-json php7.1-mbstring php7.1-mysql php7.1-xml

Installing PHP 5.6

For the older PHP application depends on PHP 5. Execute the following commands for installing PHP 5.6 on your Debian 8 Jessie.

sudo apt update
sudo apt install php5.6

Also install required php modules.

sudo apt install php5.6-cli php5.6-common php5.6-curl php5.6-gd php5.6-json php5.6-mbstring php5.6-mysql php5.6-xml

Congratulation! Enjoy the development with PHP 7.2, PHP 7.1 or PHP 5.6 on Debian 8 Jessie system.