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 (How to change PHP version and extensions).

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
  • 41 Users Found This Useful
Was this answer helpful?

Related Articles

How to access WHM?

We provide WHM access only to our customers on Reseller hosting, Cloud/VPS Hosting and Dedicated...

Can i use phpMyAdmin outside cPanel?

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

What is an Inode or File Usage indicator in cPanel?

An inode is a record in a disk table, which contains information about a file or folder such as...

How to reduce the number of inodes my account uses?

The number of inodes equals the total number of files and folders on your web hosting account. In...

How to access cPanel?

1) Note: This point is for shared hosting customers!You can access cPanel from Customer Area...