Hi Ondřej,
First of all, thanks for maintaining the PHP packages. Much appreciated.
I understand from this thread, as well as bug #1004350) that it's
intentional that only one version of PHP can be installed on Debian.
Nonetheless, I had to find a way to run PHP 7.4 next to PHP 8.1, as two
web applications I frequently use (Horde and phpLDAPadmin) are not yet
compatible with PHP 8.x.
Below a summary of what I did, as this may be useful for others having
similar issues as well:
1. manually modify the dependencies of php-common to allow PHP 7.4 to be
installed
2. install PHP 7.4 and configure Apache to use PHP 7.4 for these two web
applications (only)
These steps in detail:
1. Modify dependencies of php-common
# download the package (php-common_2%3a92_all.deb)
cd /tmp
apt download php-common
# Unpack the package (this will create three files: debian-binary
control.tar.xz data.tar.xz)
mkdir deb && cd deb/
ar x ../php-common_2%3a92_all.deb
# Unpack control archive
mkdir control && cd control/
tar xf ../control.tar.xz
# Fix dependencies in control using a text editor (I used vim):
# - remove "php7.4-common" from the "Break: " statement
# - also append "-compat" after the version to prevent this package from
being overwritten with the original one
vim control
# Repack control.tar.gz
tar c * | xz -c > ../control.tar.xz
cd ..
rm -rf -- control/
# Repack deb (order important!)
ar rcs ../php-common_2%3a92_all-compat.deb debian-binary control.tar.xz
data.tar.xz
cd ..
# clean up
rm -rf -- deb/
# install package
dpkg -i php-common_2%3a92_all-compat.deb
2. Install PHP 7.4
# install PHP 7.4 packages as well as mod_fcgi (FastCGI) for Apache
apt-get install libapache2-mod-fcgid php7.4 php7.4-fpm <add further
php7.4-* packages required by your web applications>
# enable Apache2 modules
a2enmod actions fcgid alias proxy_fcgi
# note: I was already using mpm_event; but if you are using the mod_php
(prefork MPM) module with Apache, then you also need to do the following:
a2dismod php8.1 mpm_prefork
a2enmod mpm_event proxy_fcgi setenvif
a2enconf php8.1-fpm
systemctl restart apache2
3. Configure Apache to use PHP 7.4 for specific web applications (In my
case: horde and phpLDAPadmin):
I edited my site configuration (file under /etc/apache2/sites-enabled/)
and added:
<Directory ~ "^/usr/share/(horde|phpldapadmin)/">
<FilesMatch \.php$>
SetHandler
"proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
</Directory>
Cheers,
Timo