Is it possible to select different PHP versions for subdomains and folders?

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Delaney martin
    Senior Member
    • Jun 2022
    • 101

    Is it possible to select different PHP versions for subdomains and folders?

    Hello,

    We have several different subdomains created. How can we use PHP Selector to set the PHP version for each subdomain or folder?
  • Rex Maughan
    Senior Member
    • Mar 2022
    • 110

    #2
    Hello Delaney martin,

    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.
    • Firstly, log in to your cPanel
    • Now, navigate to the Software section > Select PHP Version
    • Then, 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.
    • Lastly, 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 use 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

    Comment

    Working...
    X