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
- Open the .htaccess file in the directory you wish to set a different PHP to run on.
- Copy and paste one of the code blocks below to the top your .htaccess file
- Save
PHP 8.3 .htaccess code
# php -- BEGIN cPanel-generated handler, do not edit # Set the “alt-php83” package as the default “PHP” programming language. <ifmodule mime_module> AddHandler application/x-httpd-alt-php83___lsphp .php .php5 .phtml </ifmodule> # php -- END cPanel-generated handler, do not edit
PHP 8.2 .htaccess code
# php -- BEGIN cPanel-generated handler, do not edit # Set the “alt-php82” package as the default “PHP” programming language. <ifmodule mime_module> AddHandler application/x-httpd-alt-php82___lsphp .php .php5 .phtml </ifmodule> # php -- END cPanel-generated handler, do not edit
PHP 8.1 .htaccess code
# php -- BEGIN cPanel-generated handler, do not edit # Set the “alt-php81” package as the default “PHP” programming language. <ifmodule mime_module> AddHandler application/x-httpd-alt-php81___lsphp .php .php5 .phtml </ifmodule> # php -- END cPanel-generated handler, do not edit
PHP 8.0 .htaccess code
# php -- BEGIN cPanel-generated handler, do not edit # Set the “alt-php80” package as the default “PHP” programming language. <ifmodule mime_module> AddHandler application/x-httpd-alt-php80___lsphp .php .php5 .phtml </ifmodule> # php -- END cPanel-generated handler, do not edit
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 in PHP selector apply to the ‘per directory’ version of PHP.