Knowledgebase

How to Use Multiple PHP Versions with CloudLinux and LiteSpeed on Prabhu Host Print

  • 0

Overview

With Prabhu Host's CloudLinux-powered web hosting in Nepal, you can assign different PHP versions to different directories or subdomains within your cPanel account. This is especially useful if you're running legacy applications alongside newer ones that require the latest PHP features. Thanks to CloudLinux’s Alt-PHP and LiteSpeed integration, managing this setup is easy through .htaccess.

Step 1: View Installed PHP Versions

Connect to your server via SSH and run the following command to list available PHP versions:

ls /opt/alt | grep php

You might see output like:
php56
php70
php74
php81
php82
 
These are the PHP versions currently available on your server.

Step 2: Assign PHP Version via .htaccess

To run different PHP versions in different directories, you’ll need to create or edit the .htaccess file inside the target folder.

Example 1: Use PHP 8.1 for a Directory

In public_html/.htaccess, add:

<IfModule lsapi_module>
SetHandler application/x-lsphp81
</IfModule>

Example 2: Use Different PHP Versions for Different Folders

For public_html (PHP 8.1):

<IfModule lsapi_module>
SetHandler application/x-lsphp81
</IfModule>

For public_html/old_project (PHP 7.4):

<IfModule lsapi_module>
SetHandler application/x-lsphp74
</IfModule>

This setup allows different applications to run under their compatible PHP versions on the same hosting account.

Step 3: Confirm PHP Version is Active

To verify the PHP version for each folder:

  1. Create a file called phpinfo.php in the desired directory with this content: <?php phpinfo(); ?>

  2. Visit yourdomain.com/phpinfo.php in your browser.

  3. Look for the PHP Version at the top of the output page

Conclusion

Running multiple PHP versions allows you to maintain backward compatibility for older scripts while benefiting from the performance and security of newer PHP releases. With Prabhu Host’s CloudLinux and LiteSpeed environment, this can be configured quickly using simple .htaccess rules.

Need help setting this up? Contact Prabhu Host’s support team  we're here to help!

 

Was this answer helpful?
« Back