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.
deb https://debian.octopuce.fr/snapshots/sury-php/20220701/ stretch main
Download Deb Sury’s GPG key from Octopuce, and add it to the keyring.
# wget -qO – https://debian.octopuce.fr/sury-php/apt.gpg | apt-key add –
Update the APT package index files from their sources.
# apt update
Suppose we want to install PHP 7.4 version with all the bells and whistles:
List all the available PHP 7.4 packages.
# apt search php7.4 | grep stretch | grep -v dbgsym | cut -d’/’ -f1 | xargs
We should get the following output:
libapache2-mod-php7.4 libphp7.4-embed php7.4 php7.4-amqp php7.4-apcu php7.4-apcu-bc php7.4-ast php7.4-bcmath php7.4-bz2 php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-dba php7.4-decimal php7.4-dev php7.4-ds php7.4-enchant php7.4-fpm php7.4-gd php7.4-gearman php7.4-geoip php7.4-gmagick php7.4-gmp php7.4-gnupg php7.4-grpc php7.4-http php7.4-igbinary php7.4-imagick php7.4-imap php7.4-inotify php7.4-interbase php7.4-intl php7.4-json php7.4-ldap php7.4-lua php7.4-lz4 php7.4-mailparse php7.4-maxminddb php7.4-mbstring php7.4-mcrypt php7.4-memcache php7.4-memcached php7.4-mongodb php7.4-msgpack php7.4-mysql php7.4-oauth php7.4-odbc php7.4-opcache php7.4-pcov php7.4-pgsql php7.4-phalcon4 php7.4-phpdbg php7.4-pinba php7.4-propro php7.4-protobuf php7.4-ps php7.4-pspell php7.4-psr php7.4-radius php7.4-raphf php7.4-readline php7.4-redis php7.4-rrd php7.4-smbclient php7.4-snmp php7.4-soap php7.4-solr php7.4-sqlite3 php7.4-ssh2 php7.4-stomp php7.4-swoole php7.4-sybase php7.4-tideways php7.4-tidy php7.4-uopz php7.4-uploadprogress php7.4-uuid php7.4-vips php7.4-xdebug php7.4-xhprof php7.4-xml php7.4-xmlrpc php7.4-xsl php7.4-yac php7.4-yaml php7.4-zip php7.4-zmq php7.4-zstd
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.
# apt install libapache2-mod-php7.4 libphp7.4-embed php7.4 php7.4-amqp php7.4-ast php7.4-bcmath php7.4-bz2 php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-dba php7.4-decimal php7.4-dev php7.4-ds php7.4-enchant php7.4-fpm php7.4-gd php7.4-gearman php7.4-geoip php7.4-gmp php7.4-gnupg php7.4-grpc php7.4-http php7.4-igbinary php7.4-imagick php7.4-imap php7.4-inotify php7.4-interbase php7.4-intl php7.4-json php7.4-ldap php7.4-lua php7.4-lz4 php7.4-mailparse php7.4-maxminddb php7.4-mbstring php7.4-mcrypt php7.4-memcache php7.4-memcached php7.4-mongodb php7.4-msgpack php7.4-mysql php7.4-oauth php7.4-odbc php7.4-opcache php7.4-pcov php7.4-pgsql php7.4-phalcon4 php7.4-phpdbg php7.4-pinba php7.4-propro php7.4-protobuf php7.4-ps php7.4-pspell php7.4-psr php7.4-radius php7.4-raphf php7.4-readline php7.4-redis php7.4-rrd php7.4-smbclient php7.4-snmp php7.4-soap php7.4-solr php7.4-sqlite3 php7.4-ssh2 php7.4-stomp php7.4-swoole php7.4-sybase php7.4-tideways php7.4-tidy php7.4-uopz php7.4-uploadprogress php7.4-uuid php7.4-vips php7.4-xdebug php7.4-xhprof php7.4-xml php7.4-xmlrpc php7.4-xsl php7.4-yac php7.4-yaml php7.4-zip php7.4-zmq php7.4-zstd
Enable PHP 7.4 as the default PHP version for your operating system CLI.
# update-alternatives –config php
Enable PHP 7.4 as the default PHP version for Apache HTTP Server.
# a2enmod php7.4
Restart the Apache HTTP Server.
# systemctl restart apache2
Done.