An apt upgrade just broke php on debian 9. The problem was that mod-php8.1 was enabled by the process forcing all websites to run on PHP8.1 with mod-php, breaking a lot of sites that depend on other php versions.
From the log:
Setting up libapache2-mod-php8.1 (8.1.6-1+0~20220517.17+debian9~1.gbp6b3bd1) ...
apache2_invoke: Enable module php8.1
And, if you have installed mod_php, the best thing you can do is uninstall it. Virtualmin will have put in mod_php directives for all of your sites to disable mod_php for those sites, though, so you’ll need to clean that up (mod_php is very disruptive, breaking all other execution modes in a variety of ways if it is not accommodated in the Apache config).
I think it is important to point out that we never (willingly and directly) did. We are talking here about (old) Debian 9 systems that have been (back in the days) installed the usual way and with no significant modification … with one notable exception: the addition of Sury’s repositories in order to install different PHP versions. And this is probably where the shoe pinches…
Same here: I am not aware of deliberately adding mod-php to my systems. On both Debian 9 and 10 it was installed after installing a clean Debian and then running the virtualmin setup script and restoring 1 or a few websites.
Double checked by installing Debian 10 with Virtualmin from scratch and no mod-php is installed.
mod-php was probably installed after enabling multiple PHP versions from the sury.org repository. Not totally sure, but it looks like sury.org PHP packages used to install libapache2-mod-php. The good news: today it did not do that anymore. That or I just messed up by copy & pasting instructions and not taking notice.
I plead innocence, as I had no idea that mod-php was evil. For quite some time Virtualmin seemed to be able to cope with it, but as a fellow programmer I totally understand that you want to rip out the code that costs you a lot of time to maintain.
If you install a package named php (or php<VERSION>-php you will get mod_php). That’s a stupidity in the packaging, as it intuitively seems like maybe you’d want a package named “php” if you’re trying to install PHP, but if you’re following our docs for installing additional PHP versions that won’t happen.
Back before Virtualmin 6, we installed mod_php as part of the default install (I tried to get rid of it much earlier but got shouted down by about half of our users…I ran a poll and everything…if was almost evenly split, I should have just made the executive decision to kill it even then, and provide instructions for adding it, for users that want it). There was a bug in the Ubuntu metapackages up until a year and a half ago, though, where it was still getting pulled in, and I feel miserable about that because mod_php is just so toxic and people don’t notice it until it breaks things. Maybe that same bug was in the Debian 9 metapackages…I don’t recall fixing it there, but it’s plausible.
Check on the list of installed PHP related packages:
dpkg -l | grep -E "libapache2-mod-php|php"
… and packages like libapache2-mod-php* and php, php7.3 or php7.4 must be deleted and Apache config adjusted accordingly.
Another way of doing it is to make sure that you’re existing websites don’t use mod_php on PHP Options page and when this done, there will be a popup displayed on the Dashboard to disable mod_php for the system.
> dpkg -l | grep -E "libapache2-mod-php|php"
ii php-cgi 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all server-side, HTML-embedded scripting language (CGI binary) (default)
ii php-cli 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all command-line interpreter for the PHP scripting language (default)
ii php-common 2:92+0~20220117.43+debian10~1.gbpe0d14e all Common files for PHP packages
ii php-curl 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all CURL module for PHP [default]
ii php-fpm 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all server-side, HTML-embedded scripting language (FPM-CGI binary) (default)
ii php-imagick 3.6.0-4+0~20220117.35+debian10~1.gbp149f82 amd64 Provides a wrapper to the ImageMagick library
ii php-intl 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all Internationalisation module for PHP [default]
ii php-mbstring 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all MBSTRING module for PHP [default]
ii php-mysql 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all MySQL module for PHP [default]
ii php-pear 1:1.10.13+submodules+notgz+2022032202-2+0~20220330.37+debian10~1.gbpfd4c1d all PEAR Base System
ii php-ssh2 1.3.1+0.13-6+0~20220117.24+debian10~1.gbpe1a643 amd64 Bindings for the libssh2 library
ii php-xml 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii php5.6-cgi 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 server-side, HTML-embedded scripting language (CGI binary)
ii php5.6-cli 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 command-line interpreter for the PHP scripting language
ii php5.6-common 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 documentation, examples and common module for PHP
ii php5.6-curl 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 CURL module for PHP
ii php5.6-fpm 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php5.6-gd 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 GD module for PHP
ii php5.6-imagick 3.6.0-4+0~20220117.35+debian10~1.gbp149f82 amd64 Provides a wrapper to the ImageMagick library
ii php5.6-intl 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 Internationalisation module for PHP
ii php5.6-json 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 JSON module for PHP
ii php5.6-mbstring 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 MBSTRING module for PHP
ii php5.6-mysql 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 MySQL module for PHP
ii php5.6-opcache 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 Zend OpCache module for PHP
ii php5.6-readline 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 readline module for PHP
ii php5.6-ssh2 1.3.1+0.13-6+0~20220117.24+debian10~1.gbpe1a643 amd64 Bindings for the libssh2 library
ii php5.6-xml 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii php5.6-zip 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64 Zip module for PHP
ii php7.3-cgi 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 server-side, HTML-embedded scripting language (CGI binary)
ii php7.3-cli 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 command-line interpreter for the PHP scripting language
ii php7.3-common 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 documentation, examples and common module for PHP
ii php7.3-curl 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 CURL module for PHP
ii php7.3-fpm 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php7.3-imagick 3.6.0-4+0~20220117.35+debian10~1.gbp149f82 amd64 Provides a wrapper to the ImageMagick library
ii php7.3-intl 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 Internationalisation module for PHP
ii php7.3-json 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 JSON module for PHP
ii php7.3-mbstring 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 MBSTRING module for PHP
rc php7.3-mysql 7.3.33-1+0~20211119.91+debian10~1.gbp618351 amd64 MySQL module for PHP
ii php7.3-opcache 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 Zend OpCache module for PHP
ii php7.3-readline 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 readline module for PHP
ii php7.3-ssh2 1.3.1+0.13-6+0~20220117.24+debian10~1.gbpe1a643 amd64 Bindings for the libssh2 library
ii php7.3-xml 7.3.33-4+0~20220627.98+debian10~1.gbp40b3e4 amd64 DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii php7.4-cgi 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 server-side, HTML-embedded scripting language (CGI binary)
ii php7.4-cli 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 command-line interpreter for the PHP scripting language
ii php7.4-common 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 documentation, examples and common module for PHP
ii php7.4-curl 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 CURL module for PHP
ii php7.4-fpm 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php7.4-gd 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 GD module for PHP
ii php7.4-imagick 3.6.0-4+0~20220117.35+debian10~1.gbp149f82 amd64 Provides a wrapper to the ImageMagick library
ii php7.4-intl 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 Internationalisation module for PHP
ii php7.4-json 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 JSON module for PHP
ii php7.4-mbstring 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 MBSTRING module for PHP
ii php7.4-mysql 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 MySQL module for PHP
ii php7.4-opcache 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 Zend OpCache module for PHP
ii php7.4-readline 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 readline module for PHP
ii php7.4-ssh2 1.3.1+0.13-6+0~20220117.24+debian10~1.gbpe1a643 amd64 Bindings for the libssh2 library
ii php7.4-xml 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 DOM, SimpleXML, XML, and XSL module for PHP
ii php7.4-zip 1:7.4.30-3+0~20220627.69+debian10~1.gbpf2b381 amd64 Zip module for PHP
ii php8.0-cgi 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 server-side, HTML-embedded scripting language (CGI binary)
ii php8.0-cli 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 command-line interpreter for the PHP scripting language
ii php8.0-common 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 documentation, examples and common module for PHP
ii php8.0-curl 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 CURL module for PHP
ii php8.0-fpm 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php8.0-gd 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 GD module for PHP
ii php8.0-imagick 3.6.0-4+0~20220117.35+debian10~1.gbp149f82 amd64 Provides a wrapper to the ImageMagick library
ii php8.0-intl 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 Internationalisation module for PHP
ii php8.0-mbstring 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 MBSTRING module for PHP
ii php8.0-mysql 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 MySQL module for PHP
ii php8.0-opcache 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 Zend OpCache module for PHP
ii php8.0-readline 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 readline module for PHP
ii php8.0-ssh2 1.3.1+0.13-6+0~20220117.24+debian10~1.gbpe1a643 amd64 Bindings for the libssh2 library
ii php8.0-xml 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 DOM, SimpleXML, XML, and XSL module for PHP
ii php8.0-zip 1:8.0.21-1+0~20220713.39+debian10~1.gbpf1402f amd64 Zip module for PHP
ii php8.1-cgi 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 server-side, HTML-embedded scripting language (CGI binary)
ii php8.1-cli 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 command-line interpreter for the PHP scripting language
ii php8.1-common 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 documentation, examples and common module for PHP
ii php8.1-curl 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 CURL module for PHP
ii php8.1-fpm 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
ii php8.1-imagick 3.6.0-4+0~20220117.35+debian10~1.gbp149f82 amd64 Provides a wrapper to the ImageMagick library
ii php8.1-intl 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 Internationalisation module for PHP
ii php8.1-mbstring 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 MBSTRING module for PHP
ii php8.1-mysql 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 MySQL module for PHP
ii php8.1-opcache 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 Zend OpCache module for PHP
ii php8.1-readline 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 readline module for PHP
ii php8.1-ssh2 1.3.1+0.13-6+0~20220117.24+debian10~1.gbpe1a643 amd64 Bindings for the libssh2 library
ii php8.1-xml 8.1.8-1+0~20220711.23+debian10~1.gbp5e9cbc amd64 DOM, SimpleXML, XML, and XSL module for PHP
ii webmin-php-pear 1.5 all Webmin module for 'PHP Pear Modules'
I also ran a system recheck which told me that:
The following PHP execution modes are available : cgi fcgid fpm
I am used to using FPM from other systems I have running DirectAdmin and found the sites on the box set to FCGID and changed them to FPM and they still all appear to operate.
I am also used to having chroot jails for the users on my other systems. I enabled a chroot jail for an existing site on my system by navigating to: Administrative Options > Edit Owner Limits > Other Restrictions
and once there, I set “Chroot jail domain Unix user?” to “Yes”.
Once I did that, and the site stopped working, only displaying a notice indicating it could no longer connect to its database.
I went back in and turned it off and the site worked once again.