Different php version for directory

Hello, right now it is possible to have different versions of PHP installed on the server, however, my question is whether it can be forced in a particular directory to be able to use a specific PHP version.

Let’s imagine that for the domain www.domain.com, the PHP version is 7.4, but there is a folder within that domain, where version 8.0 is required. Is it possible to do it perhaps by forcing the loading of said version of PHP with some .htaccess?


It might work with a special apache2 / nginx config
We do the same for phpmyadmin config.

1 Like

puff…very complex (i think…), i’m plesk with openlitespeed it’s very easy:

For php7.4
<FilesMatch “.(php4|php5|php3|php2|php|phtml)$”>
SetHandler x-httpd-lsphp-74

For php7.3
<FilesMatch “.(php4|php5|php3|php2|php|phtml)$”>
SetHandler x-httpd-lsphp-73

For php7.2
<FilesMatch “.(php4|php5|php3|php2|php|phtml)$”>
SetHandler x-httpd-lsphp-72

any solution similar is it possible?

It should be possible if you are using apache…

You can try it offcourse

i’ve this error with this:

[Tue Nov 02 11:55:26.354787 2021] [proxy:error] [pid 606318:tid 140280174982912] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed

<IfModule !mod_php7.c>
    <FilesMatch ".+\.ph(ar|p|tml)$">
        SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"

hi, any @admin can help me with this?

Default folder is /var/run/php/