The issue is that Virtualmin currently only supports a single version of PHP FPM and seems to want to use PHP 7.2 no matter what I do, and I want it to use PHP 7.3 which is also installed. This appears to be a long-standing issue with Virtualmin.
I solved it by removing PHP 7.2 and setting PHP 7.3 as the default since it’s ok with me if I only have the latest version. If you want multiple PHP versions maybe you will have to check out the issue linked above for updates. Unfortunately this is probably going to cause another issue some day if the virtualmin-lemp-stack package updates and wants to reinstall it still as a dependency. I haven’t bothered dealing with that yet, will deal with it when the time comes.
In my case I was running Ubuntu 18.04 as my OS. I was also using the Virtualmin LEMP stack (NGINX instead of Apache).
At first I naturally wanted to try running:
apt remove php7.2
However, when I tried that I was told that it was a dependency of virtualmin-lemp-stack and I would have to remove virtualmin-lemp-stack as well if I wanted to remove it.
Apparently this is not ideal. So to reinstall I just had to run:
apt install virtualmin-lemp-stack
This will also want to reinstall php7.2 again which defeats the purpose of removing it in the first place. So now I am in an endless loop. But I remember there is some dpkg command and find out here that I can run to remove the PHP 7.2 packages while allowing me to keep virtualmin-lemp-stack:
dpkg -P --force-all php7.2 php7.2-cgi php7.2-cli php7.2-common php7.2-curl php7.2-fpm php7.2-gd php7.2-imap php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-tidy php7.2-xml php7.2-xmlrpc php7.2-xsl php7.2-zip
I tried some other things as well but they didn’t pan out too well and this is the only thing that actually worked. You will of course want to include any additional php7.2-packages you have installed on your system as well.
Along with this I had to also remove some additional files and some other things and restart some processes.
I ran this to update alternatives:
update-alternatives --set php /usr/bin/php7.3 update-alternatives --set phar /usr/bin/phar7.3 update-alternatives --set phar.phar /usr/bin/phar.phar7.3 update-alternatives --set phpize /usr/bin/phpize7.3 update-alternatives --set php-config /usr/bin/php-config7.3
I removed some folders:
rm -rf /etc/php/7.2 rm -rf /var/lib/php/modules/7.2 rm -rf /home/example.com/etc/php7.2
You can run that last one for each one of your domains.
Then I had to run the Virtualmin config check:
Now I switched all of virtual-servers to FPM by going to Server Configuration > Website Options and setting the PHP script execution mode to FPM. Now save and then restart some services:
service php7.3-fpm restart service nginx restart
You might also have to resave the PHP version under each domain by going to Server Configuration > PHP Versions and clicking Save Versions.
Sometimes it would tell me that I only had one versions available until I had everything set to FPM properly and then it would show me the version selection box but it only has one version in it which is the version I want. If you are still seeing multiple versions here or when checking the Virtualmin config then you haven’t fully removed the extra PHP version.
You also might have to switch it back to CGI and back to FPM if you ran into issues somewhere so that it regenerates the proper config values for VIrtualmin.