You may often find that you need to use different PHP versions for different websites or applications. In most cases, you can change any site's PHP version using the MultiPHP Manager in cPanel, but this only works for domains and subdomains.
This means the same PHP version will apply to any subdirectories of that domain. For example, if you have a WordPress site installed at domain.com/blog, that site will use the same PHP version applied to domain.com.
You can, however, change the PHP version of the subdirectory by modifying the .htaccess file. Here we cover the steps to manually apply a different PHP version to a subdirectory.
Related Articles
Update PHP Version with MultiPHP Manager
Edit File with File Manager
Find the Document Root of a Domain
Show Hidden Files in File Manager
Create File in File Manager
Create phpinfo Page
Change PHP Version
- Log into cPanel
- Navigate to File Manager, located under the Files section
- Navigate to the subdirectory for which you need to change the PHP version
- Locate the .htaccess file, right-click on it and click Edit
NOTE: As .htaccess starts with a "." it is a hidden file, so you will need to ensure hidden files are shown. See the guide on showing hidden files for instructions. If this file does not exist, you will need to create it. - Add the applicable AddHandler to the file
AddHandler application/x-httpd-ea-php## .php
REPLACE: ## with the PHP version you want to use, without the "."
EXAMPLE: If you want to use PHP 7.4, you would add the following:AddHandler application/x-httpd-ea-php74 .php
- Click the Save Changes button
- Use a phpinfo page to confirm the PHP version has changed