Changing PHP version on britiac3

Discussion about BCA's Internet Hosting Service
User avatar
David Gibson
DG test
Posts: 622
Joined: Thu 16 Mar 2006 23:45

Changing PHP version on britiac3

Post by David Gibson » Mon 06 Jan 2020 16:59

BCA's britiac3 server offers a choice of PHP versions. The site default is currently PHP 5.6, but you can set a different version in .htaccess. It is also possible to use cPanel's MultiPHP manager to do this which, when its settings are "applied", simply adds an "Addhandler" line (and a comment) to the end of your .htaccess file. (It does this when it cannot find the appropriate comment line already there).

However, there appears to be a bug in MultiPHP manager in that it does not do this if the .htaccess file is outside the public_html tree. (You need to watch out for this if you have sub-domains that map to somewhere outside of public_html).

Thus, the PHP version that MultiPHP manager thinks it has set is not necessarily the actual version that has been set in your .htaccess file. In other words...
  • Always set your PHP version from your .htaccess file. MultiPHP manager might indicate that a different version of PHP is being used. That does not matter unless someone (e.g. a site administrator) actually tries to helpfully "Apply" the MultiPHP manager settings to your sub-domain, in which case, your .htaccess file might be altered without your knowledge. So...
  • Admins with cpanel access should never use MultiPHP manager without verifying, afterwords, which edits (if any) it actually made to the relevant .htaccess file.
To change the PHP version from within your .htaccess file just add a line like this to the end of the file...

Code: Select all

  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
If you also want your HTML files to be parsed for PHP, just add .html to the end of the list of file-types in the above AddHandler directive.

If/when MultiPHP manager runs, its adds, to the end of your .htaccess file, the following text...

Code: Select all

# php -- BEGIN cPanel-generated handler, do not edit
# Set the "ea-php72" package as the default "PHP" programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
If anyone can shed any light on why it bothers to encapsulate that in an IfModule, please do so!

cPanel also offers a "MultiPHP editor" which is of very little use at all. It "purports" to generate PHP configuration code for for three files, .htaccess, php.ini and .user.ini. However ...
  • The code for .htaccess does not take into account the fact that britiac3 does not run PHP as an Apache module. If you run .htaccess with the code suggested by the cPanel MultiPHP editor, our server will report 500 Internal Server Error.
  • php.ini cannot be run from the location that cPanel writes to. (One has to suppose that the system's php.ini has already been configured correctly).
  • Whilst there is something to be said for writing a comprehensive .user.ini file, Im not sure that that is what cPanel supplies. If you want to configure PHP at such a level of detail, you should (I assert) get hold of the system php.ini file and edit that. The online PHP manual will tell you which directives can be included where. See...
    Info on .user.ini: http://php.net/manual/en/configuration. ... r-user.php
    Info on directives: http://www.php.net/manual/en/ini.list.php
    Info on scope: http://php.net/manual/en/configuration. ... .modes.php
this is my signature