How to Run Different PHP Versions in Subfolders with LiteSpeed Web Server
How to Run Different PHP Versions in Subfolders with LiteSpeed Web Server When you need to run multiple PHP applications on the same domain—each requiring a different PHP version—LiteSpeed Web Server’s configuration can be tricky. After extensive testing, I found the only reliable solution that actually works. The Problem Imagine this scenario: you have a demo server at demo.example.com and need to run: /ps8/ → PrestaShop 8 with PHP 8.1 /ps9/ → PrestaShop 9 with PHP 8.2 /ps17/ → PrestaShop 1.7 with PHP 8.3 The obvious approaches—using LSAPI Contexts or configuring Script Handlers at the Virtual Host level—simply don’t work as expected. What Doesn’t Work Approach 1: LSAPI App Context Creating a Context of type “LiteSpeed SAPI” seems logical: Type: LiteSpeed SAPI URI: /ps8/ LSAPI App: lsphp81 Result: Error in logs: PHP Fatal error: Failed opening required ‘LS.’ (include_path=’.:’) in Unknown on line 0 The problem? LSAPI App contexts don’t have a “Location” field in the GUI, so LiteSpeed can’t map the URI to the physical document root. Approach 2: Script Handler at Virtual Host Level Configuring Script Handlers in the Virtual Host only allows setting a server-level default. You’ll see [Server Level]: lsphp81 which applies to the entire domain,