Here is my report related to using "PHP Versions" in Virtualmin. This applies to Debian 8, 9 and Ubuntu 16, 18.
- Any Apache module php should be disabled. If it is not disabled "Server API" will indicate "Apache 2.0 Handler". Also "Loaded Configuration File" will indicate "/etc/[php_version]/apache2/php.ini", instead of "/home/[virtual_host_name]/[php_version]/php.ini.
Observation: When doing a [Re-Check Configuration] check also if any Apache module php is loaded then disable it, restarting apache service. This module is enabled by default if someone is upgrading the operating system.
- When you upgrade OS version from Debian 8 to 9, Debian 9 will install PHP 7.0 minimal by default. It is not installing php7.0-cgi which is very important to run properly FastCGI when you switch from PHP 5.6 to PHP 7.0 version in your host.
Observation: When doing a [Re-Check Configuration] check if php7.0-cli and php7.0-cgi modules are installed. If they are not install them and restart apache service.
- Server Configuration -> PHP Versions feature is not working properly. This feature allows you to switch php versions in your virtual host but is not doing the full job in background.
Observation 1: Virtualmin detects correctly all php versions. Missing /home/[virtual_host]/etc/[php_new_version] folder (e.g. for 7.0 version). Virtualmin should create this folder when switching to PHP7.0. Also this folder should have inside a configuration php.ini file.
Observation 2: When you switch php versions the symbolic link in /home/[virtual_host]/etc/php.ini is targeting correctly the file (e.g. /php5/php.ini or php7.0.ini). Switching to PHP 7.0 symlink points to php7.0 and the folder is missing see Observation1.
Observation 3.1: Virtualmin is correctly creating this file /home/[virtual_host]/fcgi/php7.0.fcgi. As it is now "PHPRC=$PWD/../etc/php7.0" if you look for this folder it is missing, see Observation1.
Observation 3.2: "exec /usr/bin/php7.0" it is a wrong command. As it is now all your php pages will become downloadable in browser. Normally it should be "exec /usr/bin/php-cgi7.0". I guess this is happening because php7.0-cgi was not install. See point 2. Virtualmin should install php7.0-cgi to make this working and using the right command in fcgi file.
In short these are the issues I found related to multiple PHP Versions in Debian 8 and 9:
Apache mod PHP, any version, should be disabled.
Install php-cgi module for all php versions if they are missing.
Create /home/[virtual_host]/etc/[php_versions] folder for every php version used in fcgi files. These folders should have a php.ini file inside.
Update symbolic link in /home/[virtual_host]/etc/php.ini to point the right php version used by virtual host.
Update command "exec /usr/bin/php[version]" to "exec /usr/bin/php-cgi[version]" in /home/[virtual_host]/fcgi/php[version].fcgi. (php-cgi module should be install before for all php-versions).
P.S. I upgraded 5 servers to the latest OS versions in this weekend all having Virtualmin. I managed to make them working based on the observations above, but manually. A white ball, Virtualmin is changing correctly sites configuration in Apache folder for every php version.