How to Set a Different PHP Version for an Addon Domain?

At ServerAdept, we use CloudLinux OS on all our servers to ensure enhanced performance, security, and stability for every hosting account. One of the key benefits of CloudLinux is the ability to select your preferred PHP version based on your website or application requirements.

This feature is especially useful if your website depends on a specific PHP version for compatibility or performance optimization.

Important Limitation in cPanel

While CloudLinux allows you to easily change the PHP version for your main domain via cPanel, it does come with a limitation:

- You cannot assign different PHP versions to Addon Domains or Subdomains directly through cPanel.

Workaround: Use .htaccess for Custom PHP Versions

Even though this option is not available in cPanel, you can still configure different PHP versions for:

- Addon Domains
- Subdomains
- Specific folders or directories

This can be achieved by using PHP handlers within your website’s .htaccess file.

By placing the appropriate handler in the desired directory, you can override the default PHP version and run a different version as needed.

Available PHP Handlers

You can switch between PHP versions by adding the corresponding handler in your .htaccess file. Below are the supported PHP handlers:

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
AddHandler application/x-httpd-alt-php83 .php .php8 .phtml
AddHandler application/x-httpd-alt-php84 .php .php8 .phtml

*** 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.

*** How to Set PHP 8.3 Version for an Addon Domain ***

Let’s have a practical example of how to set the PHP 8.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-php83” package as the default “PHP” programming language.
AddHandler application/x-httpd-alt-php83 .php .php8 .phtml
# php -- END cPanel-generated handler, do not edit

As a result, an addon domain, for instance, will use the PHP 8.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 8.4 Version for an Addon Domain ***

Let’s have a practical example of how to set the PHP 8.4 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-php83” package as the default “PHP” programming language.
AddHandler application/x-httpd-alt-php84 .php .php8 .phtml
# php -- END cPanel-generated handler, do not edit

As a result, an addon domain, for instance, will use the PHP 8.4 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.

  • 16 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

How can I change my password in cPanel?

If you remember your old password, follow the below steps after logging in to your account:...

How do I access WHM?

WHM i.e. Web Host Manager is a software interface which will allow you to easily monitor your...

How do I change Language in cPanel?

Step 1: Login to your cPanel account with your Username and Password. Step 2: Search for “Change...

How do I log in to cPanel?

Type: https://IP:2083 into your preferred Internet browser. IP is meant to stand for your...

How to create an FTP account in cPanel?

An FTP account is used to Manage and Upload files on to your Hosting Server. The FTP & cPanel...

Powered by WHMCompleteSolution