Home Web ServerHow to Install LiteSpeed Web Server on cPanel and Replace Apache

How to Install LiteSpeed Web Server on cPanel and Replace Apache

by Knowledge Base Linux
Install LiteSpeed cPanel - fast web server in a data center

If your cPanel server slows to a crawl every time traffic spikes, Apache is usually the bottleneck. Its process-based model spawns heavy workers for every connection, while LiteSpeed Web Server uses an event-driven architecture that serves far more concurrent visitors from the same RAM. The good news: when you install LiteSpeed cPanel keeps working exactly as before — same accounts, same httpd.conf, same .htaccess files — because LiteSpeed is a true drop-in Apache replacement. This guide walks hosting admins through the full process: installing the WHM plugin, activating a license, building PHP with LSAPI, testing on a port offset, and switching production traffic over safely.

Why Replace Apache with LiteSpeed on cPanel? – How to Install LiteSpeed Web Server

LiteSpeed Web Server (LSWS) was designed to read Apache configuration files directly, which is why it dominates the shared-hosting market. In practice you get:

  • Event-driven serving — thousands of concurrent connections with a tiny memory footprint compared to Apache prefork or even event MPM with PHP-FPM pools per account.
  • LSAPI PHP — a dedicated SAPI that outperforms mod_php and PHP-FPM in most hosting benchmarks, with per-user process controls that pair well with CloudLinux.
  • Built-in full-page cache — LSCache for WordPress and other apps, with no separate reverse proxy layer to maintain.
  • HTTP/2 and HTTP/3 (QUIC) support out of the box.
  • Drop-in compatibility — .htaccess and mod_rewrite rules keep working, so migrations are usually measured in minutes, not weekends.

Before You Install LiteSpeed on cPanel: Prerequisites – How to Install LiteSpeed Web Server

Before you install LiteSpeed on cPanel, confirm the following:

  • Root WHM access on a supported OS: AlmaLinux 8/9, CloudLinux 7/8/9, Rocky Linux, or Ubuntu 22.04 LTS running a current cPanel & WHM version.
  • A LiteSpeed license. LSWS is commercial software. Licenses are priced by the number of worker processes and RAM; a 15-day trial license is available and the WHM plugin can request one for you automatically. OpenLiteSpeed is the free edition, but it is not a drop-in cPanel replacement — for OpenLiteSpeed you would use a different panel such as CyberPanel instead.
  • A backup of your Apache setup. The switch is reversible, but snapshot your EasyApache 4 profile and /etc/apache2 anyway.
  • Enough free disk space for a second PHP build (a few GB is comfortable).
  • A list of your PHP versions. Every PHP version your accounts use must be rebuilt with LSAPI support, so note them down in WHM → MultiPHP Manager first.

Step 1: Install the LiteSpeed WHM Plugin

The supported way to install LiteSpeed cPanel integration is LiteSpeed’s own WHM plugin. It handles installation, licensing, PHP compilation, and switching between Apache and LiteSpeed from the GUI. Download and run the installer as root:

cd /usr/src
wget https://www.litespeedtech.com/packages/cpanel/lsws_whm_plugin_install.sh
sh ./lsws_whm_plugin_install.sh
rm -f ./lsws_whm_plugin_install.sh

When it finishes, log in to WHM and open Plugins → LiteSpeed Web Server. Everything else in this guide happens inside that plugin page.

Step 2: Install LiteSpeed and Activate the License

Inside the plugin, click Install/Uninstall LiteSpeed Web Server and start the installation. The wizard asks for:

  • Serial number — paste your purchased license key, or choose the trial option to have a 15-day trial license issued automatically.
  • Install directory — the default /usr/local/lsws is fine.
  • Port offset — leave this at 0 for now; we will use the offset feature for testing in Step 4.
  • Administrator credentials for the LiteSpeed WebAdmin console (default port 7080).

The installer downloads the latest stable LSWS release, registers the lsws service, and imports your Apache configuration. Do not switch yet — PHP is not ready.

Step 3: Compile PHP with LSAPI

This is the step admins most often skip, and the number one cause of 503 errors after a switch. LiteSpeed serves PHP through LSAPI, so each PHP version in EasyApache must have a matching LSAPI build. In the plugin, open Compile PHP with LSAPI and build every PHP version your accounts use (for example ea-php81, ea-php82, ea-php83). Keep the options aligned with your EasyApache build — same extensions, same version — so behaviour does not change for hosted sites.

Two related settings worth confirming in the plugin:

  • PHP SUEXEC — enable it so PHP runs as the account owner, matching a typical suPHP/PHP-FPM shared-hosting setup.
  • Run a PHP test after compiling — the plugin can verify each build responds correctly before you rely on it.

On CloudLinux servers, run cagefsctl --update afterwards so the new LSAPI binaries are visible inside user cages.

Step 4: Test with a Port Offset Before Switching

You do not have to bet production traffic on an untested switch. The plugin’s Port Offset feature lets LiteSpeed run alongside Apache on alternate ports (typically 2080 for HTTP and 2443 for HTTPS) while Apache keeps serving the real ports 80/443. Set an offset, restart LiteSpeed from the plugin, and browse your key sites at http://yourdomain.com:2080. Check PHP pages, WordPress logins, contact forms, and anything with complex rewrite rules. When everything works, set the offset back to 0.

Install LiteSpeed cPanel plugin from the WHM dashboard
The LiteSpeed WHM plugin manages installation, licensing, PHP builds and the Apache switch from one screen.

Step 5: Switch from Apache to LiteSpeed

Now make the change. In the plugin click Switch to LiteSpeed. The plugin stops Apache, starts LSWS on ports 80/443 with your existing configuration, and monitors the first requests. Prefer the command line? The same operation is scripted:

/usr/local/lsws/admin/misc/cp_switch_ws.sh lsws

To roll back at any time, use Switch to Apache in the plugin, or run the same script with httpd:

/usr/local/lsws/admin/misc/cp_switch_ws.sh httpd

Note that switching does not uninstall Apache — it stays installed and fully configured, which is what makes the rollback painless.

Step 6: Verify the Switch

Confirm LiteSpeed is really serving traffic:

curl -sI https://yourdomain.com | grep -i '^server'
# Server: LiteSpeed

/usr/local/lsws/bin/lswsctrl status

Then check WHM → Server Status → Service Status shows lsws up, log in to a WordPress dashboard, submit a test form, and watch the logs for the first hour:

tail -f /usr/local/lsws/logs/error.log
tail -f /usr/local/apache/logs/error_log

Verify a PHP info page reports Server API: LiteSpeed V8.x so you know LSAPI — not a leftover Apache handler — is executing PHP.

.htaccess Compatibility: What Works and What Does Not

LiteSpeed reads .htaccess files and the main httpd.conf directly. mod_rewrite rules, redirects, mod_expires-style headers, deny/allow rules, and most directives your customers use work unchanged — the reason a migration from a plain Apache LAMP stack is usually uneventful. Know the exceptions:

  • LiteSpeed emulates a subset of Apache modules. Exotic directives (mod_perl, some mod_security syntax differences) may be ignored — LiteSpeed logs them rather than failing, so review the error log after switching busy sites.
  • php_value / php_flag lines in .htaccess behave differently under LSAPI; move per-site PHP settings to .user.ini or the LSAPI configuration instead.
  • mod_security rule sets are supported through LiteSpeed’s own engine, and popular sets (OWASP CRS, Comodo, Atomic) are available in the plugin.
  • Changes to .htaccess are picked up without a restart — like Apache, unlike OpenLiteSpeed, which needs a reload for context changes.

Tips and Warnings for Production Servers

  • Match PHP after every EasyApache update. If EA updates a PHP build, re-run the LSAPI compile from the plugin, or PHP behaviour can drift between the two stacks.
  • Right-size your license. Worker-process limits on small VPS licenses can throttle very busy servers; watch the real-time stats in the WebAdmin console (port 7080) during peak hours.
  • Enable caching storage on fast media. LSCache disk cache performs best on SSD/NVMe or tmpfs.
  • Do not uninstall Apache. The plugin’s switching, PHP builds, and config generation all assume Apache’s files are present.
  • Watch stderr.log. PHP crashes under LSAPI land in /usr/local/lsws/logs/stderr.log — your first stop for post-migration debugging.

Frequently Asked Questions

Is LiteSpeed free on cPanel?

No. LiteSpeed Web Server is commercial, licensed per server with a 15-day trial available through the WHM plugin. The free OpenLiteSpeed edition cannot replace Apache inside cPanel; it is normally paired with CyberPanel or used standalone.

Will my customers’ .htaccess rules break?

Almost certainly not. Rewrite rules, redirects, and header directives are parsed directly from the same files. The main adjustments are PHP settings placed in .htaccess, which should move to .user.ini under LSAPI.

How long does the switch take, and is there downtime?

The switch itself takes under a minute and restarts the web service once, comparable to an Apache restart. The port-offset test in Step 4 lets you validate everything with zero downtime beforehand.

Can I switch back to Apache if something goes wrong?

Yes — one click in the WHM plugin (or the cp_switch_ws.sh httpd command) restores Apache with its configuration untouched.

Conclusion

To install LiteSpeed cPanel admins only need the official WHM plugin, a valid or trial license, and one discipline: always build matching LSAPI PHP before you switch. Test on a port offset, verify the Server: LiteSpeed header and PHP SAPI, and keep Apache installed as your instant rollback. Done this way, replacing Apache with LiteSpeed is one of the safest performance upgrades you can make to a hosting server — and it unlocks the next steps, such as enabling HTTP/3 and turning on LSCache for your WordPress accounts.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.