How to configure PHP Repository for Debian 9 Stretch

How to Configure PHP Repository for Debian 9 Stretch

Debian is a free and open-source Linux distribution developed by the Debian Project, starting from August 1993. It is one of the oldest operating systems based on the Linux kernel, and as of now the second oldest Linux distribution still in active development. Debian is also the basis for many other distributions including Ubuntu, Linux Mint, and Kali Linux.

Debian 9 (Stretch) LTS was released on 2017-Jun-17 and it has reached it’s EOL(End Of Life) on 2022-Jul. After this date, this version of Debian has been switched to ELTS(Extended Long Term Support) mode. This a commercial offering to further extend the lifetime of Debian releases to another 5 years. But it is an unofficial project managed by Freexian and is a paid option.

One of the consequences of this End of Life status is that Debian does not provide packages beyond the lifetime of the base distribution. And as a result of this, the once publicly available Debian 9 repository no longer exists at present.

In any webhosting environment, a common request that we have to handle is the changing of PHP versions. Since Debian 9 is EOL and the official repository is now offline, we are unable to install or update PHP versions using the default/official repository configuration.

An alternative resource that we could have used is Deb Sury.
This repository is managed by a Debian Developer since 2000. The Dev has been packaging PHP for Debian since PHP 5. That means the official packages in Debian and Ubuntu are this Dev’s work or they are based on this work. Thus, the PHP packages available here matches the official packages in Debian. Basically, what we are saying is that you cannot get any closer than that.

Unfortunately, the End Of Life announcement for Debian 9 also has influenced the decisions taken by Deb Sury. This Dev’s repository no longer builds/publishes/maintains packages for Debian 9. All PHP packages for Debian 9 were completely removed on 2022-Jul-02.

In addition to this, for making sure they are never at the mercy of third-party repositories, they have also ensured to create daily snapshots of these repositories. Besides, our Deb Sury’s Repository Snapshots can be accessed at https://debian.octopuce.fr/snapshots/sury-php/

Taking into the fact that Deb Sury had removed all the Debian 9 PHP packages on 2022-Jul-02, the Octopuce snapshot on 2022-Jul-01 and accessible at https://debian.octopuce.fr/snapshots/sury-php/20220701/ should contain all our required PHP packages.

NOTE: We would first need to follow the documentation for How to configure Main Repository for Debian 9 Stretch. Because based on the selection of PHP extensions, dependency packages might have to be retrieved from the main repository, which actually does not exist! ]

For making the Octopuce’s Deb Sury PHP Repository available for Debian 9, perform the following step:

Let us create the required APT Source configuration file for Deb Sury from Octopuce.

Create the file /etc/apt/sources.list.d/php.list with following content.

Download Deb Sury’s GPG key from Octopuce, and add it to the keyring.

Update the APT package index files from their sources.

Suppose we want to install PHP 7.4 version with all the bells and whistles:

List all the available PHP 7.4 packages.

We should get the following output:

From among the above, we chose to exclude the following packages in our test setup so that package conflicts were avoided.
php7.4-apcu, php7.4-apcu-bc, php7.4-gmagick

Install rest of the PHP packages using below command.

Enable PHP 7.4 as the default PHP version for your operating system CLI.

Enable PHP 7.4 as the default PHP version for Apache HTTP Server.

Restart the Apache HTTP Server.

Done.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top