PHP Inheritance


Last modified: August 28, 2019

Overview

In WHM’s MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager), the term “Inherit” refers to how Apache determines a domain or virtual host’s PHP version. When you set an account or domain 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, Apache uses the system default PHP version.

Important:

As of cPanel & WHM version 78, the system enables PHP-FPM by default and sets the PHP version of each account to the PHP 7.2 (ea-php72) value. You cannot set an account’s PHP version to use the Inherit option with PHP-FPM enabled.

How inheritance works

Only one single default PHP version exists in EasyApache 4’s MultiPHP environment. You set this default version at the system level. The system sets the PHP version of each new domain to the default value.

When the system searches for the version of PHP to use, it starts in the cPanel & WHM default document root of the current domain and continues up the directory tree until it finds a .htaccess file with PHP version information. Apache must locate a .htaccess file to properly inherit a PHP version from a primary domain.

  • If Apache does not find a .htaccess file, it uses the system default PHP version from WHM’s MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager).
  • If Apache finds an invalid version of PHP in the .htaccess file, it uses the system default PHP version set in WHM’s MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager).
Note:
  • For a primary domain, the default document root is the /$HOME/user/public_html directory.
  • For a subdomain or addon domain, the default document root depends on your server's settings. For more information, read our Tweak Settings documentation.
Important:

We strongly recommend that you only set the PHP version in WHM's MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager). If you set your PHP version manually, you may experience unexpected behavior.

Examples

In the following table, assume that the system uses PHP 7.1 by default. PHP inheritance follows the following path:

Note:

In the following table, the sub3.example.com and sub6.example.com domain examples are only valid if you set the Restrict document roots to public\_html option in WHM's Tweak Setting interface (WHM >> Home >> Server Configuration >> Tweak Settings) to Off

Domain Domain type PHP setting .htaccess file? Effective PHP version Document Root within the /public_html directory
example.com Primary Inherit No 7.1 Yes
sub1.example.com Subdomain Inherit No 7.1 Yes
sub2.example.com Subdomain 7.0 Yes 7.0 Yes
sub3.example.com subdomain 7.0 No 7.0 No
domain.com Primary 7.0 Yes 7.0 Yes
sub4.domain.com Subdomain Inherit No 7.0 Yes
sub5.domain.com Subdomain 5.6 Yes 5.6 Yes
sub6.example.com subdomain 5.6 No 7.0 No

Additional Documentation