First of all, you need to complete the prerequisites step and then go forward to install the PHP version of your choice or requirements.

Prerequisites

Login to your Debian 9 system using shell access. For remote systems connect with SSH. Windows users can use Putty or other alternatives applications for SSH connection. Run below commands to upgrade the current packages to the latest version. 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. Now use one of the below options to install PHP of your requirements.

Installing PHP 7.4

You can also install the latest PHP version on your system. Run the following commands to install PHP 7.4 on Debian 9. Also install required php modules.

Installing PHP 7.3

You can also install the latest PHP version on your system. Run the following commands to install PHP 7.3 on Debian 9. Also install required php modules.

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 9. Also install required php modules.

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 9 Stretch system. Also, install the required PHP modules as per your requirements. Here is a list of some frequently used modules.

Installing PHP 5.6

Execute the following commands for installing PHP 5.6 on your Debian 9 Stretch system. Also install required php modules.