You can run different PHP versions per directory on your Ecenica web hosting plan by following the steps below. This is useful if your main website uses one PHP version and you wish to test a new PHP version on your staging website.

Please note: PHP Selector sets the primary PHP version your account runs. We strongly recommend this option if you are simply wishing to change the PHP version your website or account runs. Changing PHP per directory is an advanced option.

How to change my PHP version using PHP Selector

Set PHP version using .htaccess

  1. Open the .htaccess file in the directory you wish to set a different PHP to run on.
  2. Copy and paste one of the code blocks below to the top your .htaccess file
  3. Save

PHP 7.4 .htaccess code

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php74” package as the default “PHP” programming language.
<ifmodule mime_module>
  AddHandler application/x-httpd-alt-php74___lsphp .php .php5 .phtml
</ifmodule>
# php -- END cPanel-generated handler, do not edit

PHP 7.3 .htaccess code

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php73” package as the default “PHP” programming language.
<ifmodule mime_module>
  AddHandler application/x-httpd-alt-php73___lsphp .php .php5 .phtml
</ifmodule>
# php -- END cPanel-generated handler, do not edit

PHP 7.2 .htaccess code

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php72” package as the default “PHP” programming language.
<ifmodule mime_module>
  AddHandler application/x-httpd-alt-php72___lsphp .php .php5 .phtml
</ifmodule>
# php -- END cPanel-generated handler, do not edit

PHP 7.1 .htaccess code

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php71” package as the default “PHP” programming language.
<ifmodule mime_module>
  AddHandler application/x-httpd-alt-php71___lsphp .php .php5 .phtml
</ifmodule>
# php -- END cPanel-generated handler, do not edit

PHP 7.0 .htaccess code

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php70” package as the default “PHP” programming language.
<ifmodule mime_module>
  AddHandler application/x-httpd-alt-php70___lsphp .php .php5 .phtml
</ifmodule>
# php -- END cPanel-generated handler, do not edit

Notes

  • The [PHP modules you have set(/support/answer/how-to-run-custom-php-modules-on-cpanel-hosting/) in PHP selector] apply to the ‘per directory’ version of PHP.