Sponsored Content

DEV Community

Cover image for Installing OpenLiteSpeed on Ubuntu 22.04
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya Originally published at docs.vultr.com

Installing OpenLiteSpeed on Ubuntu 22.04

OpenLiteSpeed is a free, open-source, high-performance web server with HTTP/2 and HTTP/3 support, native PHP handling, and a graphical admin console for managing virtual hosts. This guide installs it on Ubuntu 22.04, creates a virtual host with a custom web root, and secures it with a real TLS certificate.

Prerequisites: an Ubuntu 22.04 instance, non-root sudo user, a domain A record (e.g. app.example.com).


Install OpenLiteSpeed

Not in the default repos — use the official setup script:

$ wget -O openlitespeed.sh https://repo.litespeed.sh
$ sudo bash openlitespeed.sh
$ sudo apt install openlitespeed -y
$ cat /usr/local/lsws/VERSION
Enter fullscreen mode Exit fullscreen mode

Manage the Service

Runs as lshttpd.service, aliased to lsws:

$ sudo systemctl enable lshttpd.service
$ sudo systemctl start lsws
$ sudo systemctl status lsws
Enter fullscreen mode Exit fullscreen mode

Stop/restart with sudo systemctl stop lsws / restart lsws.


Access the Admin Console

Runs on port 7080; default password lives at /usr/local/lsws/admin/password.

$ sudo bash /usr/local/lsws/admin/misc/admpass.sh
Enter fullscreen mode Exit fullscreen mode

Set a custom admin username and password when prompted, then open the port:

$ sudo ufw allow 7080/tcp
$ sudo ufw reload
Enter fullscreen mode Exit fullscreen mode

Visit http://SERVER-IP:7080, accept the self-signed cert warning, log in with the credentials you just set.

Move the default listener off 8088 onto standard HTTP:

  1. Listeners → view the Default listener → Edit on Address Settings.
  2. Change Port from 8088 to 80Save.
  3. Graceful Restart (top right, next to LSWS PID) → Go.

Create a Virtual Host

$ sudo mkdir /usr/local/lsws/app.example.com
$ sudo mkdir /usr/local/lsws/app.example.com/{html,logs,conf} -p
$ sudo chown lsadm:lsadm -R /usr/local/lsws/app.example.com/
Enter fullscreen mode Exit fullscreen mode
  • html — served application files
  • logs — access/error logs
  • conf — site-specific config

In the console:

  1. Virtual Hosts → Add, replacing app.example.com with your domain:
    • Virtual Host Name: app.example.com
    • Virtual Host Root: $SERVER_ROOT/app.example.com/
    • Config File: $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
    • Follow Symbolic Link, Enable Scripts/ExtApps, Restrained: Yes
    • External App Set UID Mode: Server UID
  2. SaveCLICK TO CREATE on the config-file-missing prompt → Save again.
  3. Open the new virtual host → General → Edit:
    • Document Root: $VH_ROOT/html/
    • Domain Name: app.example.com
    • Enable GZIP Compression, Enable Brotli Compression: Yes
  4. Log → Edit (error log): Use Server's Log: Yes, File Name: $VH_ROOT/logs/error.log, Log Level: ERROR, Rolling Size: 10M, Keep Days: 30.
  5. Log → Add (access log): Log Control: Own Log File, File Name: $VH_ROOT/logs/access.log, same rolling/retention values.
  6. Rewrite → Edit: Enable Rewrite: Yes, Auto Load from .htaccess: Yes.
  7. Listeners → Default Listener → Virtual Host Mappings → Add: select your virtual host, enter app.example.com in Domains.
  8. Save, then Graceful Restart → Go.

Add a test page:

$ sudo nano /usr/local/lsws/app.example.com/html/index.html
Enter fullscreen mode Exit fullscreen mode
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>OpenLiteSpeed Server Install Test</title>
</head>
<body>
    <h1 style="text-align: center;">It works!</h1>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode
$ sudo ufw allow 80/tcp
Enter fullscreen mode Exit fullscreen mode

Visit http://app.example.com and confirm the page loads.


Secure with Let's Encrypt

$ sudo snap install --classic certbot
$ sudo certbot certonly --webroot -w /usr/local/lsws/app.example.com/html/ --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m name@example.com -d app.example.com
$ sudo certbot renew --dry-run
Enter fullscreen mode Exit fullscreen mode

Certbot doesn't have an OpenLiteSpeed plugin — wire the certificate in manually via the console:

  1. Listeners → Add: Listener Name: HTTPS, IP Address: ANY IPv4, Port: 443, Secure: YesSave.
  2. Open the new HTTPS listener → Virtual Host Mappings → Add: Virtual Host: app.example.com, Domains: app.example.com.
  3. SSL → Edit:
    • Private Key File: /etc/letsencrypt/live/app.example.com/privkey.pem
    • Certificate File: /etc/letsencrypt/live/app.example.com/fullchain.pem
    • Chained Certificate: Yes
  4. Save, then Graceful Restart → Go.

For multiple virtual hosts, open each one's SSL tab individually to bind a certificate.


Firewall Rules

$ sudo ufw allow 22/tcp && sudo ufw enable
$ sudo ufw allow 7080/tcp
$ sudo ufw allow http
$ sudo ufw allow https
$ sudo ufw reload
$ sudo ufw status
Enter fullscreen mode Exit fullscreen mode

Visit https://app.example.com to confirm TLS is working end to end.


Next Steps

OpenLiteSpeed is running with a virtual host, HTTPS, and a working test page. From here:

  • Add PHP via the console's Server Configuration → External App for dynamic sites
  • Repeat the virtual host steps per additional domain you host on the same server
  • Automate cert renewal hooks to reload the listener after Certbot rotates the certificate

For the full guide, visit the original article on Vultr Docs.

Top comments (0)