How to install OpenLitespeed server with PHP 8 on Debian 11 or Ubuntu 21
You’ll get a lightweight, blazing‑fast web server that plays well with PHP 8 out of the box. No more wrestling Apache’s mod_php or the overhead of Nginx + FPM.
1. Prerequisites – Make sure you’re ready for this
- The host must be a fresh Debian 11 (Bullseye) or Ubuntu 21.04/21.10 install.
- You need root or sudo privileges – OpenLiteSpeed owns the webroot, logs, and config files.
- If Apache is already running, stop it (systemctl stop apache2) to avoid port conflicts.
2. Add the OpenLiteSpeed repository
curl -sSL https://openlitespeed.org/packages/ols-release.deb | sudo dpkg -i - sudo apt update
The official repo contains the latest stable Litespeed binaries and the lsphp8 package we’ll need. Skipping this step forces you to build from source, which is a pain and leaves you with stale packages.
3. Install OpenLiteSpeed
sudo apt install -y openlitespeed
After installation you can verify:
/usr/local/lsws/admin/misc/init.sh start
If it starts without errors, you’re good to go. OpenLiteSpeed’s default control panel will be reachable at http://your_ip:7080.
4. Install the PHP 8 FastCGI module
OpenLiteSpeed bundles its own PHP‑FPM called lsphp. On Debian 11 and Ubuntu 21, the package is named lsphp80 for PHP 8.0 or lsphp81 if you want the newer minor release.
# For PHP 8.0 sudo apt install -y lsphp80 # Or, on Debian 11 with 8.1 available: # sudo apt install -y lsphp81
Why use lsphp instead of system‑wide PHP? It isolates the web server from the rest of your OS, so you can safely upgrade or downgrade without breaking other services.
5. Configure OpenLiteSpeed to use PHP 8
1. Log into the admin panel at http://your_ip:7080. Default credentials are admin / 12345. Change the password immediately.
2. Go to Server Configuration => External App and add a new entry:
* Name: lsphp80
* Executable Path: /usr/bin/lsphp
* Port: 9000
3. In Virtual Host => Configuration => PHP Settings, set the default handler to lsphp80.
If you prefer command‑line tweaks, edit /usr/local/lsws/conf/httpd_config.conf and add:
ext_processor lsphp80 {
type application/x-httpd-php
address 127.0.0.1:9000
}
Restart the server afterward:
sudo systemctl restart lsws
6. Test PHP 8 is wired up correctly
Create a simple info.php in /usr/local/lsws/html with:
<?php phpinfo(); ?>
Navigate to http://your_ip/info.php. You should see PHP 8.0 (or 8.1) details, and the "Server API" line will read LiteSpeed. If it says Apache or FPM instead, you’ve got a misconfiguration.
7. Optional – Harden your setup
- Disable default Apache to free up port 80:
sudo systemctl disable apache2
- Enable SSL using the built‑in Let's Encrypt helper:
/usr/local/lsws/admin/misc/cert.sh --acme
Follow the prompts; it will generate and install a free cert for your domain.
- Set up a firewall rule to allow only ports 80, 443, and 7080:
sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw allow 7080/tcp
8. A real‑world tweak that saves headaches
I’ve seen sites crash after a PHP 7.4 upgrade because the old mod_security rules were still enabled in OpenLiteSpeed’s default config. The solution is to drop those legacy directives from /usr/local/lsws/conf/httpd_config.conf or switch to the newer ModSecurity2. Once removed, PHP 8 runs smoothly without the “unexpected token” errors that used to bite me.
That’s it—OpenLiteSpeed with PHP 8 up and running. If you hit a snag, the logs in /usr/local/lsws/logs will tell you what went wrong. Happy serving!