How to Set the PHP Version per Folder

How to Set the PHP Version per Folder

Do you have a single domain or wish to use different PHP versions per folder? Do you have an installed PHP 5.X software in a folder/blog and want to use a PHP 7.X version instead? If so, you can do this using cPanel and the .htaccess file.

  1. Login to your cPanel account.

    https://brienne.zebrahost.net/cpanel

  2. In the Software section, click on the MultiPHP Manager icon.

    image

  3. Assume that we are new to this and the first thing we will need to do is to get the code generated by cPanel.

  4. Scroll down tp the end of the page, select your domain from the left side and you will se the first option “PHP Version” with a drop-down list on the right side. Select the appropriate PHP version from the drop-down menu and click the Apply button.

    image

  5. Now open the /public_html/.htaccess file in the cPanel File Manager or in your FTP client and you will find the code generated by cPanel.

    image

  6. After you copy the code, you will need to set the PHP version to version 7 in the folder/forum, which means you will need to create a .htaccess file in the folder “/forum/” and paste the code which was generated in the previous step in it.

  7. Congratulations! Now your folder/forum uses PHP 7, and if you wish to set any other folder to use the same version of PHP as well, you will only need to copy the code from the .htaccess file and paste it into that folder.

Reset Your PHP Version from Your Main Domain

If you wish to use a different PHP version on any folder you will need to follow steps 5 and 8 to generate the code. Copy that code from “/public_html/htaccess” and paste it into any folder where you wish to set your selected PHP version.