How to set up different PHP Versions in different folders /domains /subdomains from cPanel account

PHP is a popular open-source general–purpose scripting language developed for web development and can be embedded into HTML. In some cases, we need to access the project’s different PHP versions and cPanel’s built–in functions that allow us to change the PHP Version directly.

The newly released PHP Version supports new features like Enums, Fibers, Intersection Types, and ready-only properties. In cPanel, select the PHP version and MultiPHP Manager, it’s easy to access the different PHP versions for a domain, an Addon domain, and a subdomain.

This document will help you to set use a different PHP version for various domains, an Addon domain, and a subdomain. You can use different PHP versions for different domains.

Step 1: You’ve to log in to cPanel

 

Step 2: After login to cPanel. Move to domains >> Tab on Domains

 

 

Step 3: Click on the domain that you want to change the PHP Version. Select the document root for that domain (e.g. chjds.com) and click on blog.chjds.com > document root for that subdomain. You’re redirected to the file manager of that subdomain.

 

On the top right of the file manager, click on Settings.

 

Step 4: Take your arrow to the Show Hidden Files (dotfiles) section, and click to save.

 

Step 5: Locate the .htaccess file, and right-click on it to edit it.

 

Step 6: Insert the following lines in the bottom of the .htaccess file, and click on Save Changes on the top right.

<FilesMatch “\.(php4|php5|php3|php2|php|phtml)$”>

SetHandler application/x-httpd-alt-php71___lsphp

</FilesMatch>

 

The above code will enable the PHP version 7.1 for the directory. You can edit the “php71’ in the above code to get the desired PHP version as per your requirement.

For ex: if you require PHP version 7.3 then type “php73” and click on save changes.

 

Leave a Reply