Knowledgebase

Different PHP versions per directories using mod_lsapi

To use different PHP versions for specific directories, you'll need to configure it through your web server's configuration files. Here's a general outline of the steps you would follow:

  1. Install and Enable mod_lsapi:

    • Make sure that mod_lsapi is installed and enabled on your web server. Refer to LiteSpeed's documentation for specific installation instructions.
  2. Configure PHP Versions per Directory:

    • Create a .htaccess file in the directory where you want to use a different PHP version.

    • Inside the .htaccess file, add the following line to specify the desired PHP version:

      bash

 

    • LSAPI_Apache2_HANDLER application/x-httpd-lsphp<version>

      Replace <version> with the desired PHP version (e.g., 5.6, 7.2, etc.).

    • Save the .htaccess file.

  • Restart the Web Server:

    • After making changes, restart the webserver to apply the configuration.
  • Verify PHP Version:

    • Create a PHP file (e.g., info.php) in the directory where you added the .htaccess file. Add the following content to it:

      php

 

    • <?php phpinfo();
    • Access this PHP file through a web browser to check the PHP version being used.

  1. Repeat for Other Directories:

    • If you need to use different PHP versions in other directories, repeat steps 2-4 for each directory.

Remember, this approach assumes that mod_lsapi is properly installed and configured on your web server. Additionally, always make sure to thoroughly test any changes in a controlled environment before applying them in a production setting.

If you're using a control panel like cPanel or Plesk, they might have their own interfaces for managing PHP versions on a per-directory basis. Refer to the documentation of your specific control panel for instructions on how to achieve this.

 
  • 0 Users Found This Useful
Was this answer helpful?