What's new
Your Hosting Talk

Welcome to Your Hosting Talk! Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Is it Possible to select different PHP versions for sub-domains and folders?

Scott_H

Member
Hello,

I have several different subdomains created. How can I use PHP Selector to set the PHP version for each subdomain or folder?
 

Rex_Maughan

New member
Hello,

I have several different subdomains created. How can I use PHP Selector to set the PHP version for each subdomain or folder?


Hello Scott_H,

PHP Selector is a tool that enables users on the server to have their own fully customizable and flexible PHP environment. It allows the user to switch between different PHP Versions, such as PHP 5.2, PHP 5.3, PHP 5.6, PHP 7.0, and PHP 7.1, based on the user's needs.

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.

You can follow the steps below to configure the PHP versions for your subdomains or directories PHP Selector.
  • Login to your cPanel
  • Navigate to the Software section > Select PHP Version
  • Now, select the desired PHP version from the drop-down list, click Set as current and Save the change.

Thus, a new PHP version is now enabled for each subdomain or folder. You can also use different PHP versions per directories by using mod_lsapi,
  • Firstly, setup mod_lsapi
  • Now, for EasyApache 4 servers - you should already have a /etc/container/php.handler file.
  • You will have to create a .htaccess file in the desired directory where you want a different PHP version with the correct handler.

Include the below code to the .htaccess file for the EasyApache4 server:
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-ea-php71-lsphp
</FilesMatch>

As a result, subdirectories will utilize the same PHP version as the parent until you overwrite it with another .htaccess entry under that subdirectory.

I hope the above information helps you set the PHP version for each subdomain or directory using PHP Selector.

-----------------------------------
Regards,
Rex_Maughan
 
Top