[Solved] Install Scripts Need PHP5 and Fail Despite Multiple PHP Versions Installed and PHP5 Default

The problem was that the line at /usr/share/webmin/virtual-server/php-lib.pl:34:

local ($dir) = grep { $->{‘words’}->[0] eq $pdir ||
$
->{‘words’}->[0] eq $pdir."/" }
&apache::find_directive_struct(“Directory”, $vconf);

Directories of the form /home/*/public_html don’t match. I replaced the asterisk with the virtual server name and things worked again.

Moreover, at line 54, there is:
return ‘mod_php’;
Which executes if there is no match in the virtual server’s directives above – which explains how I could be getting a “mod_php” when apachctl reported no php modules at all.

------ The original question follows -----
Installed multiple versions of PHP with the packages.sury.org/php/ repository.

php

php php5.6 php5dismod php5-fpm php7.0 php-cgi phpdismod phpquery
php5 php5-cgi php5enmod php5query php7.1 php-cgi7.0 phpenmod

php -v

PHP 5.6.30-0+deb8u1 (cli) (built: Feb 8 2017 08:50:21)
Copyright © 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright © 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright © 1999-2016, by Zend Technologies

update-alternatives --set php /usr/bin/php5

However, Virtualmin -> Install Scripts -> Wordpress still reports This script cannot be installed, as it requires PHP version 5. And Virtualmin -> Server Configuration -> PHP Versions reports: This virtual server is using the mod_php execution mode for PHP, such does not allow per-directory version selection. I installed the php repo that supports multiple versions with: #!/bin/bash # To add this repository please do:

if [ “$(whoami)” != “root” ]; then
SUDO=sudo
fi

${SUDO} apt-get install apt-transport-https lsb-release ca-certificates
${SUDO} wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
${SUDO} sh -c ‘echo “deb https://packages.sury.org/php/ $(lsb_release -sc) main” > /etc/apt/sources.list.d/php.list’
${SUDO} apt-get update

The installed php packages:

apt list --installed |egrep ‘php(5|7)’

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libapache2-mod-php5/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
libapache2-mod-php5.6/unknown,now 5.6.30-11+0~20170522123046.34+stretch~1.gbp3d9cea amd64 [installed,automatic]
libapache2-mod-php7.0/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed,automatic]
libapache2-mod-php7.1/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php5-cgi/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5-cli/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5-common/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5-fpm/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5-gd/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5-json/now 1.3.6-1 amd64 [installed,local]
php5-mcrypt/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5-mysqlnd/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5-mysqlnd-ms/now 1.6.0-1+b1 amd64 [installed,local]
php5-readline/now 5.6.30+dfsg-0+deb8u1 amd64 [installed,local]
php5.6/unknown,unknown,now 5.6.30-11+0~20170522123046.34+stretch~1.gbp3d9cea all [installed]
php5.6-cli/unknown,now 5.6.30-11+0~20170522123046.34+stretch~1.gbp3d9cea amd64 [installed,automatic]
php5.6-common/unknown,now 5.6.30-11+0~20170522123046.34+stretch~1.gbp3d9cea amd64 [installed,automatic]
php5.6-json/unknown,now 5.6.30-11+0~20170522123046.34+stretch~1.gbp3d9cea amd64 [installed,automatic]
php5.6-opcache/unknown,now 5.6.30-11+0~20170522123046.34+stretch~1.gbp3d9cea amd64 [installed,automatic]
php5.6-readline/unknown,now 5.6.30-11+0~20170522123046.34+stretch~1.gbp3d9cea amd64 [installed,automatic]
php7.0/unknown,unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 all [installed]
php7.0-bz2/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed,automatic]
php7.0-cgi/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-cli/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-common/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed,automatic]
php7.0-curl/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-gd/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-imap/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-intl/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-json/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed,automatic]
php7.0-mbstring/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-mcrypt/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-mysql/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-opcache/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-pspell/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-readline/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed,automatic]
php7.0-recode/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-sqlite3/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-tidy/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-xml/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed,automatic]
php7.0-xmlrpc/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed]
php7.0-xsl/unknown,unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 all [installed]
php7.0-zip/unknown,now 7.0.19-1+0~20170522122642.31+stretch~1.gbpfcdab8 amd64 [installed,automatic]
php7.1/unknown,unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 all [installed,automatic]
php7.1-bz2/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-cli/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-common/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-curl/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-gd/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-json/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-mbstring/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-mysql/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-opcache/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-readline/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-xml/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]
php7.1-zip/unknown,now 7.1.5-1+0~20170513113444.24+stretch~1.gbpe4bc94 amd64 [installed,automatic]

Virtualmin system information:

Operating system Debian Linux 8
Webmin version 1.840
Virtualmin version 5.07
Theme version Authentic Theme 18.48
Time on system Monday, May 29, 2017 6:32 PM
Kernel and CPU Linux 4.9.15-x86_64-linode81 on x86_64
Processor information Intel® Xeon® CPU E5-2680 v2 @ 2.80GHz, 4 cores

Note the /etc/debian-version reports 9.0, not 8:

cat /etc/debian_version

9.0

Don’t use mod_php if you can possibly avoid it. That shouldn’t prevent install scripts from working, but it’s just a good idea to use mod_fcgid (or the new php-fpm support, which is currently in beta in Virtualmin, but hasn’t had any serious bugs filed against it that I’m aware of). That will allow the version code to work in Virtualmin, and it may be able to figure out what’s going on and act right. If it still misbehaves under mod_fcgid and/or php-fpm, we may be dealing with a bug (could be a bug in our mod_php support, too, but we likely won’t fix it, as it’s being deprecated and mod_php use is strongly discouraged, by both us and the PHP developers).

mod_php support is being deprecated in Virtualmin 6; it’ll be possible to turn it back on for people that really need it, but it won’t be installed or configured by default, and it’ll likely be completely removed in Virtualmin 7.

1 Like

Menu path to disable mod_php please?

There are no php modules loaded.

apachectl -t -D DUMP_MODULES |grep -i php

I still get: This virtual server is using the mod_php execution mode for PHP, such does not allow per-directory version selection.

When I set Virtualmin -> Server Configuration -> Website Options -> FCGId (run as virtual server owner) I get:
Failed to save website options : Missing or invalid website documents sub-directory
When I open Virtualmin -> Server Configuration -> Website Options -> PHP Info I see:
PHP versions installed No versions found!
However, Virtualmin -> System Settings -> Re-check Configuration says:
The following PHP versions are available : 5.6.30 (/usr/bin/php5-cgi), 5.6.30 (/usr/bin/php5.6), 7.0.19 (/usr/bin/php-cgi7.0), 7.1.5 (/usr/bin/php7.1)

@All :slight_smile: For those facing the challenge about install script failure, and or mod_php error, I suggest to use this updated documentation to install different versions of PHP for Virtualmin on various Linux distributions at Multiple PHP Versions – Virtualmin

Inside this same documentation, today I added the steps for Debian 10 Buster at Multiple PHP Versions – Virtualmin

With this method you’re able to install any available PHP versions repository. Including PHP versions 5.6, 7.0, 7.1, 7.2, 7.3, 7.4. This method easy, fast, stable, and automatically updated. As all the PHP packages are automatically configured appropriately. And optionally, without mod_php.

I agree with Joe that if possible, and if not already done, now is a good time to let go of mod_php. I suggest PHP-FPM. Because:

  • It is more recent than FCGId
  • Up to 350 times faster than mod_php if configure properly
  • PHP-FPM is maintained along side PHP core. So likely more secure and faster fixes and updates, no more messing around with suphp or suexec, or mod_php.
  • PHP-FPM has a smaller memory footprint than mod_php
  • PHP-FPM has more configuration options than FastCGI. Those are optional, but available & handy if needed.
  • Gracefully stop and start PHP worker processes without losing any queries

If somehow you do not have access to PHP-FPM, as second choice I suggest FCGId

Thanks to the Ubertus team for this updated documentation

1 Like