How to Set the PHP Version per Folder?
cPanel's MultiPHP Manager does not support per-folder PHP version selection. You can achieve this by pointing a subdomain at the target folder and setting its PHP version separately, or by adding a handler directive in that folder's .htaccess file if PHP-FPM is disabled.
You cannot set a PHP version per folder in cPanel’s MultiPHP Manager. To run a different PHP in one folder, either point a subdomain at that folder and set its PHP version in MultiPHP Manager, or add a handler in that folder’s .htaccess if PHP-FPM is not enabled.
Before you start
- In cPanel, open MultiPHP Manager and note if PHP-FPM is enabled for your domain. The per-folder .htaccess method will not work with PHP-FPM.
- Check MultiPHP Manager shows the PHP version you need. If it is missing, open a support ticket so we can install or enable it.
- Decide which folder needs a different PHP and what subdomain you will use, for example blog.yourdomain.tld mapped to public_html/blog.
Step 1: Point a subdomain at the folder and set its PHP version (recommended)
- In cPanel, open the Domains section and create a subdomain such as blog.yourdomain.tld, setting its document root to the folder that needs a different PHP version, for example public_html/blog. The exact button wording varies between cPanel versions; what you are after is a new subdomain whose document root is that folder rather than a new folder of its own.
- Go to MultiPHP Manager. Find the new subdomain. Set its PHP version. If you change PHP-FPM here, be aware that enabling or disabling FPM on a domain that shares a document root applies to all domains using that same document root.
- Test the subdomain URL to confirm the application runs on the intended PHP version.
Undo: In MultiPHP Manager, set that subdomain back to Inherit if you want it to follow the parent version. In the cPanel Domains section you can remove the subdomain, or change its document root back to the original folder if you no longer need the split.
Step 2: If you cannot use a subdomain, add a handler in that folder’s .htaccess
- In MultiPHP Manager, turn off PHP-FPM for the domain that contains this folder. The per-folder handler works with the suPHP/CGI style handlers and will not take effect with PHP-FPM. Do not do this if that document root is shared by other domains that rely on FPM.
- Determine the exact handler string your account uses. Do not guess it. Look in the domain’s document root .htaccess for an existing AddHandler line, or open a support ticket and we will confirm the correct value for your target PHP version. Examples vary by handler.
- Create or edit the .htaccess file inside the specific folder and add a block like:
Replace “#” with the minor version, for example 1 for 8.1 or 2 for 8.2, and replace the handler string with the exact one that applies on your account. This method is not for PHP-FPM or any “PHP Selector”.<IfModule mime_module> AddHandler application/x-httpd-ea-php8# .php .php8 .phtml </IfModule> - Test a PHP info page in that folder to confirm the version.
Undo: Remove the AddHandler block from that folder’s .htaccess. In MultiPHP Manager, set the domain’s version as required and re-enable PHP-FPM if you turned it off.
If it does not work
- Nothing changes in that folder: PHP-FPM is still enabled for the domain. Turn off PHP-FPM for that domain or use the subdomain method. Note: changing FPM on one domain affects any other domains that share the same document root.
- PHP files download or you see 403/500 errors: the handler string is wrong or unsupported. Delete the AddHandler block you added so the site comes back under the domain’s MultiPHP setting, then get the correct handler value from us.
- You cannot select the PHP version you want in MultiPHP Manager: it is not installed or available for your account. Open a support ticket and we will review and install or enable the version if suitable.
What next
If you want somewhere safe to test a plugin or a new PHP version first, copy the site into a folder, point a subdomain at that folder using Step 1, and set that subdomain’s PHP version in MultiPHP Manager before you touch the live site. If you are unsure which version your application needs, or the handler string is not behaving, open a support ticket and we will check the account and tell you what is set where.
Common questions
Can I set a different PHP version for a single folder in cPanel?
No, MultiPHP Manager does not support per-folder PHP selection. Instead, point a subdomain at that folder and set the PHP version for the subdomain, or use an .htaccess handler if PHP-FPM is disabled.
What is the recommended way to run different PHP versions in different folders?
Create a subdomain pointing to the target folder, then set its PHP version separately in MultiPHP Manager. This is more reliable than .htaccess handlers.
Will .htaccess handlers work with PHP-FPM?
No. The .htaccess handler method only works with suPHP or CGI-style handlers. You must disable PHP-FPM on the domain before using this method.
What should I do if changing the PHP version per folder does not work?
Check that PHP-FPM is disabled for that domain, verify you are using the correct handler string, or confirm the desired PHP version is installed on your account. Contact support if you need the correct handler value.
Was this article helpful?
0 people found this helpful