Using the MultiPHP Manager and the PHP Selector on different domains on the same cPanel account can be confusing. This document explains how the webserver (Apache or LiteSpeed) knows which version of PHP to use. Before we jump into that, there are a few things you should know.
- The MultiPHP Manager interface lets you set a version of PHP for each document root.
- The document root is the "starting point" where the webserver looks for content. By default, the primary domain for the account has the document root of "/home/cPanelUser/public_html/". When creating an addon domain, the document root usually looks like "/home/cPanelUser/public_html/addon.domain" - the addon domain gets its own folder for a document root. If you add an Aliased domain, it will share the document root (and virtual host) of the domain you aliased it on, instead of giving it a unique location.
- A Virtual host is a set of configurations for serving one or more domains.
- If you have two domains using the same folder for their document root, they must use the same PHP version. You cannot use a different version of PHP for an Aliased domain, for instance.
- The PHP Selector interface allows you to set one version of PHP for the entire cPanel account. The PHP Selector's significant advantage is that you can customize the PHP Extensions per cPanel account instead of server-wide.
- It is possible to set PHP Selector versions per-directory when using either the lsapi or the suPHP handlers by using the command line. See the articles on CloudLinux's site for more information on doing so with suPHP or lsapi. This article does not cover those use cases.
The web server knows which version of PHP to use by comparing the default version on the server (the native version) to the version used by a particular domain in the MultiPHP Manager. If the versions match, the web server uses the version chosen by the PHP Selector. It does not matter if the versions match because the domain is set to inherit the default version or explicitly set to that specific version. As long as the versions match, the web server will defer to the PHP Selector version. However, we strongly encourage you to set the MultiPHP Manager version to "inherit" if you wish to use PHP Selector. This will ensure that the PHP Selector continues to be used even if the default version on the server changes.