The server-wide default
Make sure the new lsphp version is actually installed first. The packages live in LiteSpeed's repo:
# Check what's available
ls /usr/local/lsws/ | grep lsphp
# Install lsphp 8.3 with the modules most apps need:
sudo apt install lsphp83 lsphp83-common lsphp83-curl lsphp83-imagick \
lsphp83-imap lsphp83-intl lsphp83-mysql lsphp83-opcache \
lsphp83-redis lsphp83-memcached
Then in WebAdmin:
- Open WebAdmin at
https://your-server:7080and log in. - Go to Server Configuration → External App.
- Click the edit pencil next to LiteSpeed SAPI App (named "lsphp" by default).
- Change the Command field. The path is relative to
/usr/local/lsws/. To switch from PHP 8.2 to 8.3 you'd changelsphp82/bin/lsphptolsphp83/bin/lsphp. - Save, then click the Graceful Restart button (the spinning arrow icon, top right).
A graceful restart leaves existing lsphp child processes alive until their idle timeout (often 5+ minutes). On busy servers I've seen mixed-version behaviour for a frustrating few minutes after the change. sudo reboot — or sudo killall lsphp && sudo systemctl restart lsws — gets you to a clean state immediately.
Per-vhost: different PHP versions per site
If one site needs an old PHP for legacy reasons but the rest are on the latest, define a separate External App per version, then point each vhost at the one it needs.
- In WebAdmin, Server Configuration → External App → Add.
- Type: LiteSpeed SAPI App. Name it descriptively, e.g.
lsphp83. Address:uds://tmp/lshttpd/lsphp83.sock. Command:lsphp83/bin/lsphp. - Save and graceful-restart.
- Edit the vhost that needs the alternative version: Virtual Hosts → (your vhost) → Script Handler. Add a handler with Suffix
php, type LiteSpeed SAPI, namelsphp83. - Save and restart.
Now .php requests routed through this vhost go through the handler you just created, while every other vhost stays on the server-wide default.
Verify which lsphp is actually serving requests
The fastest sanity check is a one-line PHP info file:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php
# Visit https://yoursite/phpinfo.php
# Look at the very top — "PHP Version 8.3.x"
Then delete that file. phpinfo() exposes a lot of host detail you don't want indexed by Bing.
From the command line, you can confirm which binary is hot:
ps -ef | grep lsphp
# /usr/local/lsws/lsphp83/bin/lsphp ...
# /usr/local/lsws/lsphp83/bin/lsphp ...
Don't forget the OPcache reset
If you have OPcache enabled (you should), changing the PHP version invalidates all of its cached bytecode. The first request to each script after the switch will be slow as it gets recompiled. On a high-traffic site this is worth doing during a maintenance window.
For more graceful warm-up, ship a tiny pre-warm script that require()s your hot files and hit it with curl after the switch.