How to select a different PHP version on each folder

First, you can select your preferred PHP version across the hosting account from cPanel as explained in this article.

You can select a different PHP version on each folder under your hosting account. This allows you to run different PHP scripts with different requirements on the same account.

 

To do so, use the following code in .htaccess file inside the folder in question:

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php73
</FilesMatch>

 

The above code will use PHP 7.3. To change the version, edit the last part of the second line of the code php73 

If you want to run PHP 5.6 change php73 to php56 and if you want to run PHP7.4, change php73 to php74 and so on.

 

Note: This code will use alt-php provided by CloudLinux.

  • php version
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to create an Email Account on cPanel

Please do the following to create an Email account on cPanel: Login to cPanel Look for Email...

Can i use phpMyAdmin outside cPanel?

The phpMyAdmin tool available in cPanel is bundled with it and can be used only if you are...

Domain (example.com) has exceeded the max defers and failures per hour

If you are receiving an error similar to "Domain example.com has exceeded the max defers and...

How to access cPanel?

You can access cPanel directly using your domain or server IP in the following...

How to change PHP version and extensions (cPanel on CloudLinux)

We're going to explain how to change the PHP version and install required PHP extensions to run...