Websites & apps

How to change the PHP version in OpenLiteSpeed (LSPHP)

Switch an OpenLiteSpeed server or a single site to a newer PHP version by installing the matching LSPHP packages, pointing the external app at the new binary, adding extensions and editing the right php.ini.

IntermediateLinux server5 min read

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 sudo and 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:

Bash
ls -d /usr/local/lsws/lsphp*

List versions the repository offers. On Ubuntu and Debian:

Bash
apt-cache search lsphp | grep -E '^lsphp[0-9]+ '

On AlmaLinux and Rocky:

Bash
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:

Bash
sudo apt install lsphp84 lsphp84-common lsphp84-mysql lsphp84-curl lsphp84-intl lsphp84-imagick

On 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:

Bash
/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.txt

Lines 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.

  1. In WebAdmin, go to Server Configuration → External App.
  2. Edit the LSPHP entry (often named lsphp).
  3. Change Command to the new binary:
   /usr/local/lsws/lsphp84/bin/lsphp
  1. Optionally rename the entry, for example to lsphp84, so it is clear which version it runs.
  2. Save, then go to Server Configuration → Script Handler and make sure the php suffix uses this external app.
  3. 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:

  1. Open the virtual host and go to External App. Click + and choose type LiteSpeed SAPI App.
  2. Set Name to lsphp84, Address to uds://tmp/lshttpd/example_lsphp84.sock, Max Connections to a value such as 10, and Command to /usr/local/lsws/lsphp84/bin/lsphp. Save.
  3. Go to the vhost's Script Handler tab, click +, set Suffixes to php, Handler Type to LiteSpeed SAPI, and Handler Name to lsphp84. Save.
  4. 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:

Bash
/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:

INI
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120

PHP processes stay running between requests, so the change only takes effect after you restart them:

Bash
sudo /usr/local/lsws/bin/lswsctrl restart
sudo killall lsphp 2>/dev/null || true

The 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:

Bash
echo '<?php phpinfo();' | sudo tee /var/www/example.com/html/info.php

Open 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:

Bash
sudo rm /var/www/example.com/html/info.php

Warning: 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 -v to 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/php file. Use the path from php -i.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.