I’m wondering how to specify the PHP version to use in a specific directory of a website.
Also, is it possible to be able to use .htaccess to control which PHP version to use instead of Virtualmin? I’ve done it before but it doesn’t seem to work under Virtualmin.
Go to the domain hit php options and change it there … you can also set the directory versions there also . You may have to reload the vmin page in order to see the directory bit … tbf it’s been a while since i did it.
Domain->server settings->php options
First, mod_fastcgi is not fcgid, and second, you can’t use fcgid execution mode safely in AlmaLinux 9 (or 8). We no longer recompile Apache for suexec docroot to be in /home.
fcgid execution mode is not an option for this system.
Ubuntu and Debian can use fcgid because they have a suexec-custom package that allows arbitrary suexec docroot. But, FPM is still the preferred/recommended execution mode.
@Jamie and I were discussing it the past … I mean, making PHP-FPM to work on directory basis. I remember it was possible, and I think this is the way to go for the future, so we could with a light heart drop all other PHP execution modes, and just have PHP enabled/disable mode instead, to make it nice and simple…
There are plans, but it’s not going to happen within the next few weeks. Our plan is to eventually deprecate all other execution modes, as they’re all worse than FPM on most fronts (performance, memory, security, ease-of-use/maintenance/troubleshooting, etc.).
Generally, it’s a good practice to consolidate your apps as much as possible to use the same current version of PHP. (Though I get that sometimes that’s not feasible, due to third party proprietary apps or whatever taking a long time to update.)
In the meantime, you’d need to do it some other way; either different domains for each app that needs a different PHP version, or manually configure it.
But, you may want to just try your apps (or read the docs for the app, if you didn’t write them yourself) with one version of PHP and see how much needs to change. It’s usually not a lot when going from an old version to a newer one. Going from PHP 7 to PHP 8 is usually very easy, and there are guides from the PHP devs about making it work. Sometimes there are options you can change in your PHP configuration to make old behavior available in new versions. That’s a better idea than running a bunch of PHP versions, usually.