Setting PHP-FPM Per Directory

bumba000

Member
Aug 2, 2014
9
0
1
cPanel Access Level
Root Administrator
Hi All,
I have just purchased hosting on a VPS server with Cpanel including MultiPHP. I have created a domain and assigned php7.1. I then created two subdomains with a folder inside of the first domain as the root directory. I then assigned php7.3 to both new subdomains.

I have done what is described here, but it is not working. Here's what I did

DOMAIN: mysite.com

SD: kbase.mysite.com DR: mysite.com/kbase set to PHP7.3

SD: travis.mysite.com DR: mysite.com/travis set to PHP7.3


I have set up all three subdomains and they as subdomains with a different document root work as expected. However, changing the php version for the kbase and travis subdomains does not work. In cpanel it shows the change, but using phpinfo() shows that it is not changed. placing a the phpinfo file inside any of the three directories shows PHP7.1.


I have also found another thread where someone found that mbstring wasn't installed and that caused php-fpm to not work as expected. I have confirmed that mbstring is installed on each php version.


Any help is greatly appreciate.


Thank You,

John
 
Last edited:

cPanelHB

Technical Analyst
Staff member
Sep 6, 2018
39
4
83
Houston
cPanel Access Level
Root Administrator
Hello,

However, changing the php version for the kbase and travis subdomains does not work. In cpanel it shows the change, but using phpinfo() shows that it is not changed. placing a the phpinfo file inside any of the three directories shows PHP7.1.
In testing this on my own server, the different PHP-FPM versions for subdomains is functioning without issue.

Visiting example.tld/phpinfo.php returns the PHP version for the primary domain, and visiting subdomain.example.tld/phpinfo.php shows a customized PHP version specific to the subdomain.

However, if you are attempting to use something like example.tld/subdomain (which is actually a subdirectory rather than a subdomain), PHP-FPM will use the PHP version for example.tld

The only workaround if you want to use different php versions on subdirectories would be to use something other than PHP-FPM.