Install and configure OpenLiteSpeed web server with SSL and PHP for high-performance hosting

Intermediate 45 min Apr 03, 2026 43 views
Ubuntu 24.04 Ubuntu 22.04 Debian 12 AlmaLinux 9 Rocky Linux 9 Fedora 41

Set up OpenLiteSpeed web server with SSL certificates, PHP LSAPI, and built-in caching for superior performance compared to Apache and Nginx. Includes security hardening and monitoring configuration.

Prerequisites

  • Root or sudo access to the server
  • Domain name pointing to server IP
  • At least 2GB RAM and 20GB disk space
  • Internet connection for package downloads

What this solves

OpenLiteSpeed is a high-performance, lightweight web server that serves as a powerful alternative to Apache and Nginx. It provides built-in caching, event-driven architecture, and native PHP LSAPI support for significantly faster PHP processing than traditional FastCGI. This tutorial shows you how to install OpenLiteSpeed, configure virtual hosts with SSL certificates, optimize performance with caching, and implement security hardening for production environments.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you get the latest security patches and dependencies.

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget curl gnupg2 software-properties-common
sudo dnf update -y
sudo dnf install -y wget curl gnupg2 epel-release

Add OpenLiteSpeed repository

Add the official OpenLiteSpeed repository to get the latest stable version with security updates.

wget -O - https://repo.litespeed.sh | sudo bash
sudo apt update
sudo rpm -Uvh http://rpms.litespeedtech.com/releases/centos/release-el$(rpm -E %{rhel})-1.noarch.rpm
sudo dnf update -y

Install OpenLiteSpeed and PHP

Install OpenLiteSpeed web server along with PHP LSAPI for optimal performance and compatibility.

sudo apt install -y openlitespeed lsphp82 lsphp82-common lsphp82-mysql lsphp82-curl lsphp82-json lsphp82-opcache
sudo dnf install -y openlitespeed lsphp82 lsphp82-common lsphp82-mysql lsphp82-curl lsphp82-json lsphp82-opcache

Set OpenLiteSpeed admin password

Configure the WebAdmin console password for managing OpenLiteSpeed through the web interface.

sudo /usr/local/lsws/admin/misc/admpass.sh
sudo systemctl enable lsws
sudo systemctl start lsws
Note: The WebAdmin console will be accessible at https://your-server-ip:7080 using the credentials you just set.

Configure firewall rules

Open the necessary ports for HTTP, HTTPS, and OpenLiteSpeed WebAdmin access. For comprehensive firewall configuration, see our Linux firewall hardening guide.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 7080/tcp
sudo ufw --force enable
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --permanent --add-port=7080/tcp
sudo firewall-cmd --reload

Create directory structure for virtual hosts

Set up the standard directory structure for hosting multiple websites with proper permissions.

sudo mkdir -p /var/www/example.com/html
sudo mkdir -p /var/www/example.com/logs
sudo chown -R nobody:nogroup /var/www/example.com
sudo chmod -R 755 /var/www/example.com
Never use chmod 777. It gives every user on the system full access to your files. The nobody:nogroup ownership with 755 permissions provides secure access for the web server.

Create a test PHP file

Create a simple PHP file to verify that PHP LSAPI is working correctly with OpenLiteSpeed.

Server API: " . php_sapi_name() . "";
?>
sudo chown nobody:nogroup /var/www/example.com/html/info.php
sudo chmod 644 /var/www/example.com/html/info.php

Configure virtual hosts and SSL

Access WebAdmin console

Open your browser and navigate to the OpenLiteSpeed WebAdmin console to configure virtual hosts.

https://your-server-ip:7080

Log in with the admin credentials you created earlier. The WebAdmin interface provides a user-friendly way to configure virtual hosts, SSL certificates, and performance settings.

Configure virtual host via WebAdmin

Create a virtual host through the web interface for better configuration management and validation.

  1. Navigate to Virtual Hosts tab
  2. Click Add to create a new virtual host
  3. Set Virtual Host Name: example.com
  4. Set Document Root: /var/www/example.com/html
  5. Set Enable Scripts: Yes
  6. Click Save

Configure PHP for virtual host

Set up PHP LSAPI processing for optimal performance compared to traditional FastCGI implementations.

  1. Go to Virtual Hostsexample.comPHP
  2. Set PHP Version: lsphp82
  3. Set Initial Request Timeout: 60
  4. Set Retry Timeout: 0
  5. Click Save

Install SSL certificate with Certbot

Install Let's Encrypt SSL certificates for secure HTTPS connections using Certbot.

sudo apt install -y certbot
sudo certbot certonly --webroot -w /var/www/example.com/html -d example.com -d www.example.com
sudo dnf install -y certbot
sudo certbot certonly --webroot -w /var/www/example.com/html -d example.com -d www.example.com

Configure SSL listener

Set up HTTPS listener in OpenLiteSpeed WebAdmin console for secure connections.

  1. Navigate to Listeners tab
  2. Click Add to create HTTPS listener
  3. Set Port: 443
  4. Set Secure: Yes
  5. Set Certificate File: /etc/letsencrypt/live/example.com/fullchain.pem
  6. Set Private Key File: /etc/letsencrypt/live/example.com/privkey.pem
  7. Click Save

Map virtual host to listeners

Connect your virtual host to both HTTP and HTTPS listeners for complete web server functionality.

  1. Go to ListenersDefault (Port 80)Virtual Host Mappings
  2. Click Add and set:
  3. Virtual Host: example.com
  4. Domains: example.com, www.example.com
  5. Repeat for HTTPS listener (Port 443)
  6. Click Graceful Restart

Enable caching and performance optimization

Enable built-in caching

Configure OpenLiteSpeed's high-performance built-in cache to dramatically improve page load times.

  1. Navigate to Virtual Hostsexample.comCache
  2. Set Enable Cache: Yes
  3. Set Cache Root: /tmp/lshttpd/cache/example.com
  4. Set Cache Policy:
checkPrivateCache    1
checkPublicCache     1
maxCacheObjSize      10000000
maxStaleAge          200
qsCache              1
reqCookieCache       1
respCookieCache      1

Configure PHP OPcache

Optimize PHP performance with OPcache configuration for faster script execution.

opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2
opcache.fast_shutdown=1
opcache.enable_cli=0
opcache.save_comments=0
sudo systemctl restart lsws

Configure compression

Enable GZIP compression to reduce bandwidth usage and improve page load speeds.

  1. Go to ActionsServer ConfigurationTuning
  2. Set Enable GZIP Compression: Yes
  3. Set GZIP Compression Level: 6
  4. Set Compressible Types: text/*, application/x-javascript, application/javascript, application/json
  5. Click Save and Graceful Restart

Security hardening

Configure security headers

Add modern security headers to protect against common web vulnerabilities and attacks.

  1. Navigate to Virtual Hostsexample.comHeaders
  2. Add response headers:
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
Content-Security-Policy: default-src 'self'; img-src 'self' data: https:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'
Strict-Transport-Security: max-age=31536000; includeSubDomains

Configure access control

Implement access controls and request limits to prevent abuse and DDoS attacks.

  1. Go to ActionsServer ConfigurationSecurity
  2. Set Access Denied Directories: .ht, .svn, .git, .env
  3. Set Per Client Throttling → Static Requests/sec: 1000
  4. Set Per Client Throttling → Dynamic Requests/sec: 100
  5. Set Connection Limit: 10000
  6. Click Save

Secure WebAdmin console

Restrict WebAdmin access to specific IP addresses and change the default port for enhanced security.

  1. Navigate to ActionsAdmin SettingsGeneral
  2. Set Admin HTTP Port: 7443 (or another non-standard port)
  3. Set Allowed List: 203.0.113.10 (replace with your admin IP)
  4. Click Save and restart
sudo systemctl restart lsws

Set up monitoring and backups

Configure log rotation

Set up automatic log rotation to prevent disk space issues and maintain system performance.

/usr/local/lsws/logs/.log /var/www//logs/*.log {
    daily
    missingok
    rotate 30
    compress
    delaycompress
    sharedscripts
    postrotate
        /bin/kill -USR1 cat /usr/local/lsws/logs/httpd.pid 2>/dev/null 2>/dev/null || true
    endscript
}
sudo chmod 644 /etc/logrotate.d/openlitespeed

Create backup script

Implement automated backups of website content and OpenLiteSpeed configuration files.

#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/backup/openlitespeed"

mkdir -p $BACKUP_DIR

Backup website files

tar -czf $BACKUP_DIR/websites_$DATE.tar.gz /var/www/

Backup OpenLiteSpeed configuration

tar -czf $BACKUP_DIR/lsws_config_$DATE.tar.gz /usr/local/lsws/conf/

Backup SSL certificates

tar -czf $BACKUP_DIR/ssl_certs_$DATE.tar.gz /etc/letsencrypt/

Remove backups older than 7 days

find $BACKUP_DIR -name "*.tar.gz" -mtime +7 -delete echo "Backup completed: $DATE" >> /var/log/ols-backup.log
sudo chmod 755 /usr/local/bin/ols-backup.sh
sudo mkdir -p /backup/openlitespeed

Schedule automated backups

Set up daily automated backups using systemd timers for reliable backup execution. For comprehensive disk monitoring, see our disk usage monitoring guide.

sudo crontab -e
0 2   * /usr/local/bin/ols-backup.sh

Verify your setup

sudo systemctl status lsws
curl -I http://example.com/info.php
curl -I https://example.com/info.php
sudo /usr/local/lsws/bin/lshttpd -t
php82 -v
lscpu | grep -E '^Thread|^CPU\(s\)'

Check the WebAdmin console at https://your-server-ip:7080 and verify that your virtual host is serving content correctly. The info.php page should show "Server API: litespeed" confirming PHP LSAPI is working.

Performance comparison

FeatureOpenLiteSpeedApacheNginx
PHP ProcessingNative LSAPI (fastest)mod_php/FastCGIFastCGI/FPM
Built-in CachingYes (LSCache)Requires modulesBasic proxy cache
Event-drivenYesPartiallyYes
Memory UsageLowHighVery Low
Web InterfaceFull WebAdminThird-party onlyThird-party only
.htaccess SupportYesYesNo

Common issues

SymptomCauseFix
503 Service UnavailablePHP process limit reachedIncrease Max Connections in Virtual Host PHP settings
SSL certificate errorCertificate paths incorrectVerify paths in Listeners → SSL tab match certbot output
PHP not processingScript handler not configuredCheck Virtual Host → PHP settings and script handlers
Permission denied errorsIncorrect file ownershipsudo chown -R nobody:nogroup /var/www/site
WebAdmin console inaccessiblePort blocked by firewallCheck firewall rules and Admin HTTP Port settings
Cache not workingCache directory permissionsEnsure /tmp/lshttpd/cache is writable by nobody user

Next steps

Automated install script

Run this to automate the entire setup

#openlitespeed #litespeed #web-server #php-lsapi #ssl-certificates

Need help?

Don't want to manage this yourself?

We handle infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.

Talk to an engineer