Switch PHP version manually?

I migrated an old CentOS 7 version to RHEL 9. Those were running older PHP 7 versions. On the new systems I installed the latest 8 with Remi repo per the official Virtualmin docs this is what they recommend now to run multiple PHP versions, but for one site that will not be exposed to the public I need to keep it on version 7.x The latest package for remi on RHEL 9 is PHP 7.4. That is the lowest PHP package on the repo.

I know that Virtualmin now uses FPM by default. In the past it was FCGI and with suexec, but I read on the forums that Joe said they don’t ship their compiled Apache version anymore. Now here is my problem which they probably did to switch it to /home

The transferred sites were set up as FCGI but with the latest PHP 8 version and they work fine. on the new server, so the settings were transferred to Virtualmin, they are still on FCGI but using the latest detected highest PHP version with is 8.2 T

The default OS PHP is 8 on the server, and I also see the remi PHP’s 8.2 and 7.4 I installed. So far so good. All 3 PHP versions show in Virtualmin.

Now here comes the problem. The sites running on FCGI, once switched to FPM cannot be switched back. Which is fine, I don’t care since they will run on the latest PHP anyway.

When I try to switch back out of FPM it says suexec is compiled for /var/www and not home, I know this error exactly what it is, that is the default apache path and since now Virtualmin does not ship its own Apache version anymore, which is good for security since we can patch directly from the vendor, suexec is obviously broken. I don’t care since I don’t need it, but Virtualmin can’t switch PHP without it.

But the same issues is true when you try to switch PHP on FCGI mode.

When Virtualmin detects the PHP versions installed, it said both 8.0 and 8.2 are FPM ready, so it clearly cannot switch to 7.4 using FPM.

Do you see the problem already?

If I switch a site to FPM I can switch PHP versions between 8.0 and 8.2, but PHP 7.4 is not where to be selected because Virtualmin already detected is a not compatible with FPM.

If I leave the sites just like they were transferred from the old servers in FCGI mode, I can select all 3 PHP versions in the dropdown, including 7, but I cannot set them from Virtualmin without hitting the error. So basically I cannot switch the old sites to run PHP 7.

I tested the PHP 7.4 on the site by executing it directly internally, and it does work. I also tried setting the handler directly in the Virtual Host in Apache manually :
/home/site/fcgi-bin/php7.4.fcgi

No luck, on the web server it will execute the same version that Virtualmin shows for the site, which is obviously not 7.4 since I cannot switch from Virtualmin

I created a new site assuming some weird suexec config was transfered with the old site in the configuratio, but it has the same issue. So it appears that switching PHP versions is now only supported in FPM which I cannot run for this PHP 7.4.

Sure, I could recompile Apache, but then I’m going backwards again. All I need is to force Virtualmin to ignore the suexec error since It’s not actually using suexec from what I know, I checked the virtual host configuration and the suexec line that existed in the old servers are gone on the new one, so the transfer correctly removed this old setting in the apache configuration files, and under the server default template, the option suexecFCGI does not exist either just FCGI alone as opoosed to the old CentOS 7 server.

To resume, what does Virtualmin actually do when you switch PHP versions? Because I need to force this manually. Or else, how do I keep the sites in the current mode FCGI, and just change the configuration manually. Note that I did not, nothing strange here, these are sites that where officially running in PHP 7 with the default Virtualmin settings that was the default many years back. I dont think CGI or FCGI is supported anymore, at least I have no idea why it would complaint about the suexec when its a new installation and on a clean system and Virtualmin basically did all the installation and config, the only additional thing I installed as the PHP extra versions from remi per the docs. Nothing else.

I managed to get Virtualmin to recognize the PHP versions but editing the symlink for the php in the bin folder and php.ini

If I post a php file inside the users account and then execute PHP to check the PHP version its running, it is now correct but for some reason on the website it still loads the previous FPM PHP version.

So Virtualmin recognizes and the proper PHP version is set, but somehow I need to force the site to use this PHP version when served from the Apache web server.

It seems I was missing the FPM package for PHP 7, once installed I could just switch to FPM which at least is better than nothing but the issue I described basically is still true. It seems the options in PHP are completely useless and don’t anything anymore. All sites run in FPM regardless of what you actually see in that selection, so the sites that had FCGI selected once transfered, its false, they are actually running as FPM, not only you cannot switch the mode but even the option Disable PHP entirely does nothing.

Basically the setting PHP script execution mode does not work anymore. I think at least the Disabled option should be fixed in some future. Because I see how some people might to disable PHP on some sites.

I believe this is a known bug that’s fixed in the upcoming Virtualmin release. (At least, I’m pretty sure it’s the same thing that’s being discussed in a ticket in Pro support right now.)

Good to know, I just used FPM for all migrated sites, but I do would love the option to be able to selective disable PHP entirely for some sites in the future that don’t require it, or don’t want someone being able to execute any script at all (static HTML site only).

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.