HostArmada Web Hosting Knowledge Base

Knowledge is power! Use that power and achieve total and unconditional control over the Web Hosting Services!

How can I utilize different PHP versions in different directories on HostArmada Shared Hosting plans?

Having the ability to change your PHP version on a directory basis is very sought after, especially by clients running multiple websites. Being able to set multiple PHP versions on your account will allow you to test newer PHP versions on staging websites before deploying them to your live site.

Another useful application of this feature is being able to run old projects which you have not found the time to update yet and are using an older PHP version, such as PHP 7.2 or PHP 8.2 for example. Taking advantage of this will not compromise the speed and security of the rest of your websites running on the account by globally changing to an older PHP version.

You can have the latest PHP 8.2 running globally for the account and then use the method we are about to explain for the older web applications. To set this up, you need to know how to use the .htaccess file. If you are not sure how to do that, please take a look at our article on What is a .htaccess file and where can I find it. When you have selected a method of editing the “.htaccess” file, and you have opened it, please insert one of the following lines, depending on the PHP version you want to use:

PHP 5.6

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

PHP 7.0

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

PHP 7.1

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

PHP 7.2

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

PHP 7.3

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

PHP 7.4

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

PHP 8.0

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

PHP 8.1

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

PHP 8.2

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

The above method of changing your PHP version per directory will work only for our Shared Hosting Plans. If you are using our VPS or Dedicated CPU servers, then you should check out our How to use the MultiPHP Manager feature in the WHM tutorial. If you do not feel confident doing this on your own, feel free to contact our technical support team over the ticketing system in your Client Area.

Was this article useful and on point?

Find out more about HostArmada entire range of optimized Web Hosting Services and take action today on improving your website Loading Speed, Security, and overall Stability!