cPanel 140 Recently updated 3 min read

How to Set the PHP Version per Directory in cPanel

How to Set the PHP Version per Directory in cPanel

Do you want to use different PHP versions for different directories? You can achieve this using cPanel and the .htaccess file.

Steps to Set the PHP Version

  1. Log in to your cPanel account.
  2. In the Software section, click on MultiPHP Manager.
  3. The first thing you need to do is generate the code using cPanel.
  4. Scroll down to the bottom of the page. Select your domain from the left side of the screen. You can view the PHP version from the drop-down menu on the right. Select the appropriate PHP version and click on Apply.
  5. Open the /public_html/.htaccess file in the cPanel File Manager to find the code generated by cPanel.
  6. After copying the code, if you wish to set the PHP version to 8 in the directory /forums/, create a .htaccess file in that directory and paste the code generated in the previous step.
  7. Congratulations! Now your /forums/ directory is using PHP 8. If you want to set any other directory to use the same PHP version, simply copy the code from the .htaccess file and paste it into that directory.

If you wish to use a different PHP version in any directory, follow steps five and six again: generate the code, copy it from /public_html/.htaccess, and paste it into the desired directory.

Related articles

Discussion

Loading the discussion…