PHP Setup with multiple versions

#1
Hi.

I am new to LiteSpeed / LSAPI (after many years using Apache and PHP-FPM). With PHP-FPM we would create a php-fpm config file for each vhost which specified the pool settings like which user/group to run as, the unix socket, connection settings, and any php config tweaks we wanted (via php_admin_value). Within the apache vhost configuration we then mapped .php files to the desired php-fpm socket. This allowed us set per-vhost, the PHP version, user/group to run as, and php.ini overrides.

I'm now trying to achieve the same thing with LiteSpeed and LSAPI. We are using RockyLinux10 with no control panel, and LiteSpeed is configured to run as user litespeed.

I have installed php82 and php84 from the LiteSpeed Repository. I've added both to the 'PHP Handlers' section in the webadmin.

1757141776271.png

I kind of expected that now 'lsphp82' and 'lsphp84' would be available to select in the Virtual Host -> Script Handler section. I thought I would enter Suffix: php and then select the version I wanted from the list, but they're not in the list - so it seems that it doesn't work this way.

I set up some dummy vhosts to test. It seems that if I enter a value in the 'Default PHP Versions' field, then .php files in my vhosts will start being executed, but in this case all vhosts will get the same version, and the PHP processes will run as user litespeed (as opposed to the vhost-specific user).

I have read about how you can have different suffixes to indicate the version you want. But renaming all my scripts from .php to .lsphp82 isn't really possible - it would break portability, and would mean changing 3 party library packages. I found I could change the mime type for php files per vhost by adding a Context, and get the desired PHP version that way, but it feels a bit hacky, and PHP still runs as user litespeed. I'm starting to get the impression that the settings in Server -> PHP are only useful if you want to set PHP up the same way for all your vhosts - is that right?
So what is the correct way to set up PHP so that we can:

- Select a specific version for each vhost.
- Have PHP run as the specific vhost user (IE the user that owns the docroot and the files).
- Allow the possibility of per-vhost php configuration overrides.
  • Many thanks.
 
Top