1. Home
  2. Hosting Management
  3. PHP Configuration
  4. How to Set a Different PHP Version for an Addon Domain

How to Set a Different PHP Version for an Addon Domain

ChemiCloud uses CloudLinux as the OS on our servers to improve server stability. A major feature of CloudLinux is that each account can select the PHP version they want to have for their websites.

This is super useful if you have an application that requires a specific version of PHP. However, the main disadvantage of these features is that you can’t set a different PHP version for an Addon Domain or Subdomain inside cPanel.

While this option is not available in your cPanel, it is possible to have a different PHP version for an addon domain, subdomain, or on a per-folder basis by using handlers in your site’s .htaccess file.

You can easily change the PHP version on your account by using one of the following handlers, according to your desired PHP version.

The handlers for all the PHP versions we offer are:

AddHandler application/x-httpd-alt-php56 .php .php7 .phtml
AddHandler application/x-httpd-alt-php70 .php .php7 .phtml
AddHandler application/x-httpd-alt-php71 .php .php7 .phtml
AddHandler application/x-httpd-alt-php72 .php .php7 .phtml
AddHandler application/x-httpd-alt-php73 .php .php7 .phtml
AddHandler application/x-httpd-alt-php74 .php .php7 .phtml
AddHandler application/x-httpd-alt-php80 .php .php8 .phtml
AddHandler application/x-httpd-alt-php81 .php .php8 .phtml
AddHandler application/x-httpd-alt-php82 .php .php8 .phtml
Need to set a global PHP version instead?

If you want to set a global PHP version for all your domains inside your cPanel, you can easily do so using the Select PHP Version feature in cPanel.

How to Set PHP 5.6 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 5.6 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php56” package as the default “PHP” programming language.
AddHandler application/x-httpd-alt-php56 .php .php7 .phtml
# php -- END cPanel-generated handler, do not edit

As a result, an addon domain, for instance, will use the PHP 5.6 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 7 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 7 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

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

As a result, an addon domain, for instance, will use the PHP 7 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 7.1 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 7.1 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

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

As a result, an addon domain, for instance, will use the PHP 7.1 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 7.2 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 7.1 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

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

As a result, an addon domain, for instance, will use the PHP 7.2 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 7.3 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 7.3 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

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

As a result, an addon domain, for instance, will use the PHP 7.3 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 7.4 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 7.4 version for one of your Addon Domains.

Create a .htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

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

As a result, an addon domain, for instance, will use the PHP 7.4 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 8.0 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 8.0 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php80” package as the default “PHP” programming language.
AddHandler application/x-httpd-alt-php80 .php .php8 .phtml
# php -- END cPanel-generated handler, do not edit

As a result, an addon domain, for instance, will use the PHP 8.0 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 8.1 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 8.1 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php81” package as the default “PHP” programming language.
AddHandler application/x-httpd-alt-php81 .php .php8 .phtml
# php -- END cPanel-generated handler, do not edit

As a result, an addon domain, for instance, will use the PHP 8.1 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

How to Set PHP 8.2 Version for an Addon Domain

Let’s have a practical example of how to set the PHP 8.2 version for one of your Addon Domains.

.htaccess file in the desired directory or modify an existing .htaccess file where you want to have a different from default PHP version with the following handler:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php82” package as the default “PHP” programming language.
AddHandler application/x-httpd-alt-php81 .php .php8 .phtml
# php -- END cPanel-generated handler, do not edit

As a result, an addon domain, for instance, will use the PHP 8.1 version which you’ve set for it, and not the global one set for the account in the cPanel > PHP Selector.

That’s a wrap!

Now you know how you can easily change the PHP version on your Addon domains by using one of the following handlers, according to your desired PHP version.

Updated on June 16, 2023

Was this article helpful?

Related Articles

Web hosting without headaches
Get up to 70% Off hosting plans + free domain & SSL!
👉 Start Saving

Leave a Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.