Verpex uses CloudLinux as the operating system on our servers to improve server stability. One of the main features of CloudLinux 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 that requires a specific version of PHP However, the main drawback of these features is that you cannot set a different PHP version for an Addon Domain or Subdomain in cPanel.
Your website may need to use a different PHP version than the one assigned to your entire cPanel account. Although this is not available using the PHP Selector UI, it is quite 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.
There are several applications, which can sometimes require specific versions of PHP, the PHP version is important not only for speed and performance With Verpex, all shared hosting clients can set specific PHP versions for different directories.
To set a PHP version other than the one assigned to your domain on your cPanel account, you need to add a special code to your .htaccess file. The .htaccess file is a hidden file which is read by the web server. The web server follows all the instructions contained in the file. We will explain how to run multiple PHP versions simultaneously in any directory on the very same account.
- Log in to your control panel. You can do this by reading this article.
- Navigate to the section Files -> File Manager. If you wish to edit the .htaccess file for your addon domain, find the .htaccess for the addon domain in question, and go to the public_html/youraddondomain.com folder.
- Once in the File Manager, make sure the "Show hidden files" is enabled. This will enable you to see the .htaccess file if it is hidden.
- To set a custom PHP version for your desired directory/addon domain, either select the .htaccess file and click on Edit from the toolbar, or click the file to create a new .htaccess file if it does not exist.
- Once you are inside the .htaccess file, enter the PHP handler for the version you wish to use. If there is already a handler in the file, it should be deleted or replaced with your new handler. Depending on the desired PHP version you want to use for your specific application, modify the SetHandler line in the code. The handler looks like this:
# 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
Add/replace the following line to your .htaccess file depending on the version you want to use
For PHP 5.6:
AddHandler application/x-httpd-alt-php56___lsphp .php
For PHP 7.4:
AddHandler application/x-httpd-alt-php74___lsphp .php
- After adding your configuration rules, save your changes and close the .htaccess file.
Your custom version of PHP has now been set. As a result, an addon domain/directory, 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.
The process is similar if you wish to set a different PHP version for a subdomain. 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 12 months ago