Different PHP Version in the Subdomain / Addon Domain

Different PHP Version in the Subdomain / Addon Domain

Our Cloud Hosting uses CloudLinux as the operating system on our servers to improve server stability. One of CloudLinux’s main features is that each account can select the PHP version they wish to have for their websites. This is very useful if you have an application requiring a specific PHP version. However, the main drawback of these features is that you cannot set a different PHP version for an Add-on Domain or Subdomain in cPanel.

You can change the PHP version from cPanel. To do so, go to cPanel > Select PHP Version (Select PHP version) > Apply.

If multiple sites are in cPanel, all sites will have the same PHP version if each site requires a different PHP version. Although this is not available using the PHP Selector UI, it is pretty simple to do manually. You can configure the server to use different PHP versions on your subdomains and directories by adding the SetHandler code in the .htaccess file of the folder to override the default PHP version. The change can be made as follows-

Navigate to the section, cPanel > File Manager > Click on the directory or folder where your website is located > You will see the file named .htaccess > Right-click on it and click on Edit > Then save the following code anywhere:

# 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___lsphp .php
# php -- END cPanel-generated handler, do not edit
  • Here, 74 means the PHP version will be 7.4. If you need version 8.1, replace 74 with 81. If you need version 8.2, replace 74 with 82.

For PHP Version 8.1

For PHP Version 8.2

  • This can be changed through the Handler. If the .htaccess code is already given, you can change the version code there or delete the previous code.
  • If the .htaccess file is hidden, Once in the File Manager, You can check if hidden files are enabled in Settings ( upper right corner )
  • But if it doesn’t show the .htaccess file, there is no .htaccess file. Create a new file called .htaccess
HN6

Our ethos outlines the one goal we strive for—to offer super-fast hosting alongside expert technical support, all at affordable, sustainable prices. We are here for the long term, fostering customer relationships that last a lifetime. We have already hosted more than 95000 websites for happy customers in 20 countries around the globe.

Help

©2019-2024 Host Nil• Corp  LTD. All Rights Reserved.

Untitled design