OpenLiteSpeed does not use the system php package. It runs its own PHP builds, called LSPHP, through an external app that points at a binary such as /usr/local/lsws/lsphp83/bin/lsphp. Changing PHP versions means installing the new LSPHP packages and pointing that external app, or a site's own handler, at the new binary. This guide does both and covers extensions and php.ini.
Before you start
- OpenLiteSpeed installed from the LiteSpeed repository. See Install OpenLiteSpeed web server on Ubuntu.
- SSH access with
sudoand a WebAdmin login. - A backup of your site, and a check that your application supports the target PHP version. Plugins and frameworks list this in their requirements.
Warning: A major PHP upgrade can break old code. Test on a staging copy, or switch one site at a time so you can switch back quickly.
Step 1: See what is installed and available
List installed LSPHP versions:
ls -d /usr/local/lsws/lsphp*List versions the repository offers. On Ubuntu and Debian:
apt-cache search lsphp | grep -E '^lsphp[0-9]+ 'On AlmaLinux and Rocky:
dnf list available 'lsphp*' | grep -E '^lsphp[0-9]+\.'The number in the name is the version: lsphp83 is PHP 8.3, lsphp84 is PHP 8.4.
Step 2: Install the new version and its extensions
Install the base package plus the extensions your site uses. Example for PHP 8.4 on Ubuntu:
sudo apt install lsphp84 lsphp84-common lsphp84-mysql lsphp84-curl lsphp84-intl lsphp84-imagickOn AlmaLinux and Rocky, the names are similar. Check them with dnf list available 'lsphp84*'.
To copy the extension set from your current version, compare module lists:
/usr/local/lsws/lsphp83/bin/php -m > /tmp/old.txt
/usr/local/lsws/lsphp84/bin/php -m > /tmp/new.txt
diff /tmp/old.txt /tmp/new.txtLines starting with < are modules the new version still lacks. Install the matching lsphp84-... packages until the diff is empty or only shows modules you no longer need.
Step 3: Point the server at the new version
This changes PHP for every site that uses the server-level handler.
- In WebAdmin, go to Server Configuration → External App.
- Edit the LSPHP entry (often named
lsphp). - Change Command to the new binary:
/usr/local/lsws/lsphp84/bin/lsphp- Optionally rename the entry, for example to
lsphp84, so it is clear which version it runs. - Save, then go to Server Configuration → Script Handler and make sure the
phpsuffix uses this external app. - Click Graceful Restart.
Step 4: Use a different version for one site
To run one site on PHP 8.4 while others stay on 8.3, add the external app and handler at the virtual host level instead:
- Open the virtual host and go to External App. Click + and choose type LiteSpeed SAPI App.
- Set Name to
lsphp84, Address touds://tmp/lshttpd/example_lsphp84.sock, Max Connections to a value such as10, and Command to/usr/local/lsws/lsphp84/bin/lsphp. Save. - Go to the vhost's Script Handler tab, click +, set Suffixes to
php, Handler Type to LiteSpeed SAPI, and Handler Name tolsphp84. Save. - Graceful restart.
A vhost-level handler overrides the server-level one for that site only.
Step 5: Edit the LSPHP php.ini
Each LSPHP version has its own php.ini. Find the exact path:
/usr/local/lsws/lsphp84/bin/php -i | grep -E 'Loaded Configuration File|Scan this dir'On Ubuntu and Debian it is usually /usr/local/lsws/lsphp84/etc/php/8.4/litespeed/php.ini. On AlmaLinux and Rocky it is usually /usr/local/lsws/lsphp84/etc/php.ini.
Copy over any custom settings from the old version, such as:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120PHP processes stay running between requests, so the change only takes effect after you restart them:
sudo /usr/local/lsws/bin/lswsctrl restart
sudo killall lsphp 2>/dev/null || trueThe killall line stops any idle detached PHP processes so new ones load the new settings.
Check it works
Create a temporary test file in the site's document root:
echo '<?php phpinfo();' | sudo tee /var/www/example.com/html/info.phpOpen https://example.com/info.php. Check that the PHP Version at the top is the new one, the Loaded Configuration File is the path you edited, and your settings show the new values. Then delete the file:
sudo rm /var/www/example.com/html/info.phpWarning: Never leave a phpinfo page online. It reveals paths and configuration details to anyone.
Troubleshooting
- 503 Service Unavailable after switching: the Command path is wrong or the package is not installed. Run the path from the shell with
-vto confirm it exists. - Site still shows the old version: a vhost-level handler overrides the server one, or old PHP processes are still running. Check the vhost's Script Handler and restart with
killall lsphp. - "Call to undefined function" errors: an extension is missing in the new version. Repeat the module comparison in Step 2.
- php.ini changes ignored: you edited the file for a different version, or the system
/etc/phpfile. Use the path fromphp -i.
Next steps
- Make sure rewrites still work after the switch: Make.htaccess rewrites work in OpenLiteSpeed.
- Raise upload limits properly: PHP upload limits in php.ini.
- Speed up PHP: Tune PHP OPcache.
