PHP Inheritance


Last modified: December 10, 2020

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 a cPanel 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 an .htaccess file, Apache uses the system default PHP version. The system sets the PHP version of each new domain to the default value.

Important:

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

How inheritance works

PHP inheritance follows the following path:

  1. You set the PHP version at the system level.

    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.

  2. You set a cPanel account or domain to use the Inherit option in WHM’s MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager).

  3. Apache searches the cPanel & WHM default document root of the current domain and continues up the directory tree until it finds an .htaccess file with PHP version information.

    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.

  4. Apache locates an .htaccess file with PHP version information.

  5. Each cPanel account or domain set to Inherit now uses the PHP version in the .htaccess file.

    Note:
    • If Apache does not find an .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).

Example

In the following table, the system uses PHP 7.1 by default:

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