Subdomain not inheriting PHP version of the main domain | Litespeed issue on cPanel

As you know, in cPanel Multi PHP Manager platform, it does support the ‘inherit’ method between the addon domains/subdomains and its main/primary domain.

When you set an Addon domain(if down to the level of main domain’s document root) or Subdomain to use the Inherit option, Apache uses the PHP version that exists in the first .htaccess file that it finds in the domain’s file structure. If the system cannot find a .htaccess file on the top-level domain’s file structure, Apache then uses the system default PHP version for the addon domain or subdomain.

Refer here

According to the cPanel:
The main domain example.dom default document root is /home/USER/public_html and subdomain should by default be created as /home/USER/public_html/sub

Here on the problematic account, the user had set that like, main domain to /home/USER/public_html and subdomain to /home/USER/public_html/addons/sub

Even if that is the case, according to cPanel PHP inherit feature, when apache looks up for the PHP version of the subdomain, it finds PHP inherit setting and it traverses N’th levels above to find parent .htaccess file with PHP version in it. Once it finds the parent .htaccess file with PHP version in it, the Apache inherits the same PHP version for the subdomain itself.

Here, in this case, subdomain was not inheriting PHP version of the main domain working with Litespeed web server. This is because LiteSpeed only reads 1 level above the Document Root of a subdomain. Means here, the subdomain document root the user set was /home/USER/public_html/addons/sub and main domain /home/USER/public_html, so the Litespeed webserver was traversing only maximum of one level above, ie the folder “sub -> addons”. Hence, the PHP version from the main domain wont apply.

The solution for PHP inherit to work in such cases is, you can configure the same main domain PHP version in /home/USER/public_html/addon/.htaccess manually and it would apply to as well. Else, apply the same PHP version to the subdomain through cPanel > Multi PHP Manager or CloudLinux Selector PHP(if your server is running on CloudLinux).