Use different version of PHP for specific directory?


I’ve used Virtualmin → Server Configuration → PHP Options to select PHP 5.6 to run as default for a server that’s running a super old application for a short period of time. I’d like to run phpMyAdmin, and went ahead and installed it, but phpMyAdmin pompts and says it requires PHP 7.2 I believe, at a minimum.

Is there a particular way Virtualmin likes to address .htaccess files or maybe somewhere in Virtualmin itself to let a particular directory know to use an alternate version of PHP?

Thanks for the guidance.

OS type and version ROCKY LINUX 8.5
Webmin version 1.994
Virtualmin version 7.1
Related packages PHP56, PHP72

You could install phpMyAdmin in a subserver, for exemple: phpmyadmin.yourdomain.tld there you can select another version of php and wont affect the domain.

For this there is an option in virtualmin

1 Login to the control panel
2 Select the virtualmin tab
3 From the dropdown select the server you want to apply this on
4 Expand the “server configuration” section and select “php options”
5 Expand the “PHP option for this domain” section ( if collapsed )
6 Place the checkmark in the checkbox below the “enabled” column
7 Provide the directory path,
8 From the dropdown select the needed php version
5 Save

Have fun

Kindly note that this feature is available only in older versions of Virtualmin

Good to know,

Most of my servers have been upgraded from many older releases, i use it for some of my websites where for example older WordPress installs are running and having issues due to strange custom templates that prefer older php versions.

Do you by accident know from what install point is this applicable @calport ?

Kind regards,


Currently, this feature is available for all Virtualmin versions using Apache+PHP-FCGI, and which has suexec configured to /home, rather than /var/www. For new systems it is only possible with Debian 10, 11 and Ubuntu 18.04, 20.04 and 22.04. Alma and Rocky do not have this feature implemented yet. If we ever do this, it will be done with PHP-FPM.

@tommyvirtualmin However, this can be fairly fast and easily configured manually with PHP-FPM already on Alma and Rocky. You would need to manually edit VirtualHost and add something like this:

<Directory /home/>
   <FilesMatch \.php$>
    	SetHandler proxy:unix:/var/php-fpm/16588336981966-phpMyAdmin.sock|fcgi://

… and PHP-FPM config file under /etc/php-fpm.d/16588336981966-phpMyAdmin.conf (default PHP 8 configuration location on Alma/Rocky). You can see how it’s configured already in - Services ⇾ PHP-FPM Configuration: Edit Configuration Manually page, and just copy/paste and then manually edit the socket to something unique, like /var/php-fpm/16588336981966-phpMyAdmin.sock, restarting Apache and FPM services afterwards.

@Jamie, I think implementing it with sockets must be easier than with TCP ports. Although, we would need to somehow also update options configured on UI, like php_value[max_execution_time] for all PHP-FPM configs associated with virtual server … and also clear them properly … and also restore them correctly …

I think we’d have to do this via running multiple pools per domain, one for each version. This will take some work to implement though …

Hi Jamie and Ilia,

Thanks for the extensive feedback and information. I am thankful for all the work you ( and the team ) do for web, virtual, user and cloudmin. I use the GPL versions quite a bit and have always enjoyed the use.

While i may not be able to support in the sense of payed licenses, i would like to offer helping out in testing / validation of these kind of implementations. For me there is no rush in this as i have multiple workarounds for this when needed, though if there is a point where this is released, feel free to highlight me to test it out in some different setups.


While that may be cleaner on the config side, that would likely also give trouble with jailkit jailed users, so that should be considered when setting things up / making this a feature.

I only have php 5.4 version available to use on my server to test. I switched to php 5.4 and downloaded a compatible version from phpMyAdmin - Downloads, in my case I had go back to phpMyAdmin 4.4.5. Extracted the file, then rename the folder it created to phpmyadmin. Works fine.


you maybe need to reconsider if you actually publicly run phpMyAdmin 4.4.5 that version was released somewhere early in 2016. and is known to have quite a few exploits.

for just “some” examples and their impact / risk level look at the PHPMyAdmin 4.4.5 CVE reports on I doubt it will take long before you are looking at an exploited server if you keep this open to the public.


I only testing, gone now :).
He can password protect the directory.
Also he is using php 5.6 so he can using a later version then that.

Not a bad idea, thank you for this.

Upon some studying this looks like this method using VirtualHost seems to be what I was coming across most since PHP-FPM isn’t compatible with .htaccess directives. I was a little unsure about the .sock file but I will implement this and get back to you on how it goes. Thank you Ilia.

1 Like

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