OpenLiteSpeed Instalaation and Configuration

OpenLiteSpeed is a high-rendimiento, lightweight web server designed to deliver dynamic content with exceptional speed and efficiency. With native support for PHP, Python, Ruby, and Java, built-in caching mechanisms, advanced seguridad features, and a user-friendly WebConsole management interface, OpenLiteSpeed provides a modern alternative to traditional Apache and Nginx servers. This comprehensive guide covers complete installation, configuration, and optimization of OpenLiteSpeed for production web hosting environments.

Tabla de contenidos

Introducción

OpenLiteSpeed revolutionizes web server rendimiento by delivering dynamic content at speeds previously unattainable with traditional server architectures. Built from the ground up with rendimiento in mind, OpenLiteSpeed uses an event-driven architecture, advanced caching, and efficient resource management to reduce server load while increasing throughput. With support for multiple scripting languages through built-in application servers, OpenLiteSpeed eliminates the need for external application servers, streamlining implementación and reducing infrastructure complexity.

Requisitos del sistema

OpenLiteSpeed operates efficiently on modest hardware while supporting high-traffic environments:

  • Ubuntu 16.04 LTS or later
  • Debian 8 or later
  • CentOS 7 or later
  • Minimum 512 MB RAM (2 GB recommended)
  • At least 100 MB free disk space
  • Root or sudo access
  • Port 8080 available (default HTTP)
  • Port 8443 available (default HTTPS)
  • Port 7080 available (WebConsole)
  • systemd init system

Verifica system requirements:

# Check OS version
cat /etc/os-release

# Verify available memory
free -h

# Check disk space
df -h /

# Confirm port availability
sudo netstat -tulpn | grep -E "8080|8443|7080"
sudo ss -tulpn | grep -E "8080|8443|7080"

# Verify systemd
systemctl --version

Pre-Instalaation Setup

System Update and Dependencies

# Update system packages
sudo apt update && sudo apt upgrade -y

# Install required dependencies
sudo apt install build-essential libpcre3 libpcre3-dev zlib1g-dev -y

# Install curl and wget
sudo apt install curl wget -y

# Install development tools
sudo apt install software-properties-common apt-transport-https -y

# Verify installations
gcc --version

Network Configuration

# Set hostname
sudo hostnamectl set-hostname openlitespeed.example.com

# Update hosts file
echo "127.0.0.1 openlitespeed.example.com" | sudo tee -a /etc/hosts

# Verify hostname
hostname
hostname -f

Firewall Configuration

# Enable firewall
sudo ufw enable

# Set default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow required ports
sudo ufw allow 22/tcp        # SSH
sudo ufw allow 80/tcp        # HTTP
sudo ufw allow 443/tcp       # HTTPS
sudo ufw allow 8080/tcp      # OpenLiteSpeed HTTP
sudo ufw allow 8443/tcp      # OpenLiteSpeed HTTPS
sudo ufw allow 7080/tcp      # WebConsole

# Verify firewall
sudo ufw status verbose

Remove Competing Web Servers

# Stop and remove Apache
sudo systemctl stop apache2
sudo systemctl disable apache2
sudo apt remove apache2 apache2-utils -y

# Stop and remove Nginx
sudo systemctl stop nginx
sudo systemctl disable nginx
sudo apt remove nginx -y

# Verify no conflicts
sudo netstat -tulpn | grep -E ":80|:443" | head -5

OpenLiteSpeed Instalaation

Adding OpenLiteSpeed Repository

# Add OpenLiteSpeed repository
sudo wget -O - http://repo.litespeedtech.com/LSCertificate.asc | sudo apt-key add -

# Add repository to sources
sudo sh -c 'echo "deb http://repo.litespeedtech.com/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/lst_debian_repo.list'

# Update package list
sudo apt update

Instalaing OpenLiteSpeed

# Install OpenLiteSpeed
sudo apt install openlitespeed -y

# Verify installation
sudo systemctl status openlitespeed

# Check OpenLiteSpeed version
/usr/local/lsws/bin/lshttpd -v

# Start service
sudo systemctl start openlitespeed

# Enable on boot
sudo systemctl enable openlitespeed

# Verify listening ports
sudo netstat -tulpn | grep lsws

Instalaing PHP

OpenLiteSpeed includes built-in PHP support:

# Install OpenLiteSpeed PHP
sudo apt install openlitespeed-php81 -y

# Or install other PHP versions
sudo apt install openlitespeed-php74 -y
sudo apt install openlitespeed-php80 -y

# Verify PHP installation
/usr/local/lsws/lsphp81/bin/php -v

# Install common PHP extensions
/usr/local/lsws/lsphp81/bin/pecl install imagick
/usr/local/lsws/lsphp81/bin/pecl install redis

# Verify extensions
/usr/local/lsws/lsphp81/bin/php -m | grep -E "imagick|redis"

Verificaing Instalaation

# Check OpenLiteSpeed service
sudo systemctl status openlitespeed

# View listening ports
sudo ss -tulpn | grep -E "lsws|8080|8443|7080"

# Test web server
curl -I http://localhost:8080

# Access default website
curl http://localhost:8080/

# Check configuration
ls -la /usr/local/lsws/
ls -la /usr/local/lsws/conf/

# View error logs
sudo tail -f /usr/local/lsws/logs/error.log

Initial Configuration

Accessing WebConsole

The WebConsole provides web-based configuration interface:

# Access WebConsole
# URL: https://your-ip:7080
# or https://your-hostname:7080

# Default credentials:
# Username: admin
# Password: 123456

# First login will prompt password change
# Set strong password (minimum 8 characters)

# Change password:
# Select: ServerName > Admin > Change Admin Password

Basic Configuration

Through WebConsole:

# Navigate: Server Configuration

# Essential settings:
# - Server Name
# - Admin Email
# - Default Language
# - Listener Port (8080 for HTTP, 8443 for HTTPS)
# - IP Address (0.0.0.0 for all interfaces)

Stopping WebConsole

For seguridad in production, disable WebConsole:

# Method 1: Via WebConsole
# Select: Server Configuration > Admin Console
# Console Address: 0.0.0.0 (disabled)
# Save configuration
# Restart OpenLiteSpeed

# Method 2: Via configuration file
sudo nano /usr/local/lsws/conf/httpd_config.conf

# Find: <adminConsole>
# Change: enable 1 -> enable 0

# Restart service
sudo systemctl restart openlitespeed

Virtual Host Configuration

Creating Virtual Hosts

A virtual host represents a website configuration:

# Navigate WebConsole:
# Virtual Hosts > New > Perform New Virtual Host

# Configuration:

# 1. Virtual Host Name
# - Name: example.com
# - Document Root: /home/user/domains/example.com/public_html
# - Enable Expires: Yes
# - Accessable L.

# 2. Context Configuration
# - Context: / (root path)
# - Location: /home/user/domains/example.com/public_html
# - Allowable Methods: GET, POST, HEAD, OPTIONS
# - Enable Expires: Yes

# 3. Virtual Host Template
# - Can use predefined template for WordPress, etc.

# Save and apply configuration

Listener Configuration

Listeners bind virtual hosts to IP:port combinations:

# Navigate WebConsole:
# Listeners > New Listener

# Configuration:

# 1. Listener Name
# - Name: HTTP (or HTTPS)
# - IP Address: 0.0.0.0 (all interfaces)
# - Port: 8080 (HTTP) or 8443 (HTTPS)

# 2. Default Virtual Host
# - Select virtual host to serve
# - This is the catch-all for requests

# 3. SSL (for HTTPS listener)
# - Enable SSL: Yes
# - SSL Protocol: TLSv1.2 or higher
# - Certificate File: /path/to/cert.pem
# - Private Key: /path/to/key.pem

# Save and apply

Virtual Host Binding

# Bind virtual host to listener:

# Navigate WebConsole:
# Listeners > Select Listener > Virtual Host Mapping

# Map virtual hosts:
# - Domains: example.com, www.example.com
# - Virtual Host: example.com

# Multiple mappings:
# - example.com -> example.com virtual host
# - api.example.com -> api virtual host
# - static.example.com -> static content host

# Apply changes and graceful restart

PHP Integration

Configuring PHP Handler

# Navigate WebConsole:
# Server Configuration > External App > New

# 1. PHP Handler Configuration
# - Name: PHP-Static (for static external processes)
# - Address: uds://tmp/lshttpd/php.sock
# - MaxConns: 10 (connections pool size)
# - Environment:
#   LSAPI_CHILDREN=10

# 2. Set Max Idle Time
# Prevents zombie processes

# 3. Command
# /usr/local/lsws/lsphp81/bin/lsphp

# Apply configuration

Per-Virtual-Host PHP Version

# Configure PHP version per virtual host:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context
# - Context: /
# - Location: Document Root
# - PHP Handler: Select configured handler

# Different versions for different hosts:
# - example.com -> PHP 8.1
# - legacy.example.com -> PHP 7.4
# - staging.example.com -> PHP 8.0

# Graceful restart applies configuration

PHP Configuration

# Edit PHP configuration:
sudo nano /usr/local/lsws/lsphp81/etc/php.ini

# Key settings for hosting:
# memory_limit = 256M
# upload_max_filesize = 100M
# post_max_size = 100M
# max_execution_time = 300
# display_errors = Off (production)
# error_log = /usr/local/lsws/logs/php_errors.log

# Verify changes:
/usr/local/lsws/lsphp81/bin/php -i | grep -E "memory_limit|upload_max"

# Restart OpenLiteSpeed
sudo systemctl restart openlitespeed

PHP Extensions

# List installed extensions:
/usr/local/lsws/lsphp81/bin/php -m

# Common extensions:
# - curl: HTTP requests
# - gd: Image processing
# - imagick: Advanced image manipulation
# - redis: Cache server
# - mysql/mysqli: Database
# - xml/json: Data formats

# Install from package manager:
sudo apt install php-curl php-gd php-mysql -y

# Or compile from source:
cd /usr/local/lsws/lsphp81/src/extensions/
./config
make
make install

# Verify extension loaded:
/usr/local/lsws/lsphp81/bin/php -m | grep extension_name

Rewrite Rules and Optimization

Static Context Configuration

# Serve static files efficiently:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context

# Create static context:
# - URI: /
# - Location: /home/user/domains/example.com/public_html
# - Allowable Methods: GET, HEAD
# - Enable Expires: Yes
# - Enable Cache-Control: Yes

# This bypasses PHP for static files
# Dramatic performance improvement

Dynamic Context Configuration

# Configure PHP context:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context

# Create dynamic context:
# - URI: /
# - Location: /home/user/domains/example.com/public_html
# - Allowable Methods: GET, POST, PUT, DELETE, HEAD, OPTIONS
# - Enable Scripts: Yes
# - Handler: PHP 8.1

# This routes dynamic requests to PHP

URL Rewrite Rules

# Configure mod_rewrite for URL rewriting:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context > Rewrite

# Enable Rewrite:
# - Enable Rewrite: Yes
# - Rules: (same format as Apache .htaccess)

# Example rewrite rules:

# WordPress-style friendly URLs:
# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /
# RewriteRule ^index\.html$ - [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /index.php [L]
# </IfModule>

# Clean URLs (remove .php extension):
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^([a-zA-Z0-9\-_/]+)$ $1.php [L]

# Apply configuration and test

Custom Error Pages

# Configure error pages:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Error Page

# Set error pages:
# - 404 Not Found: /404.html
# - 403 Forbidden: /403.html
# - 500 Server Error: /500.html

# Create custom error page files:
echo "404 - Page Not Found" > /home/user/domains/example.com/public_html/404.html

# Graceful restart applies changes

Caching Configuration

Page Cache Configuration

# Enable page caching:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Caching

# Cache configuration:
# - Enable Cache: Yes
# - Enable Private Cache: Yes
# - Cache Expiration: Set in seconds (e.g., 3600)

# Exclude from cache:
# - Extensions to exclude: .php (already excluded)
# - URLs to skip cache: /admin, /login, /checkout

Static Asset Cache

# Optimize static file expiration:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Expires

# Set expiration times:
# - Images (.jpg, .png, .gif): 1 year
# - CSS/JS (.css, .js): 1 year
# - HTML (.html): 1 day
# - Other: default

# Example:
# <ExpiresDefault "access plus 1 day">
# ExpiresByType image/jpeg "access plus 1 year"
# ExpiresByType text/css "access plus 1 year"
# ExpiresByType application/javascript "access plus 1 year"
# </ExpiresDefault>

# This reduces server load and improves client-side caching

Database Query Caching

# For WordPress or applications using database:

# Install caching plugin:
# WordPress admin > Plugins > Add New
# Search: "LiteSpeed Cache"
# Install official LiteSpeed Cache plugin

# Plugin features:
# - Page caching
# - Database query cache
# - Browser cache
# - Minification
# - Image optimization

# Configuration:
# Settings > LiteSpeed Cache > Cache
# - Enable cache: Yes
# - Cache TTL: Set appropriately
# - Enable database cache: Yes

SSL/TLS Certificate Setup

Let's Encrypt Instalaation

# Install Certbot
sudo apt install certbot -y

# Obtain certificate
sudo certbot certonly --standalone -d example.com -d www.example.com

# Certificate location
ls -la /etc/letsencrypt/live/example.com/

# Generated files:
# - fullchain.pem: Full certificate chain
# - privkey.pem: Private key
# - cert.pem: Certificate only

Configuring HTTPS Listener

# Navigate WebConsole:
# Listeners > HTTPS Listener

# SSL Configuration:
# - Enable SSL: Yes
# - Protocol: TLSv1.2 TLSv1.3
# - Cipher Suite: Default (optimal)
# - Certificate File: /etc/letsencrypt/live/example.com/fullchain.pem
# - Private Key File: /etc/letsencrypt/live/example.com/privkey.pem

# Apply configuration
# Graceful restart

SSL Auto-Renewal

# Create renewal hook for OpenLiteSpeed:
sudo mkdir -p /etc/letsencrypt/renewal-hooks/post

# Create script:
sudo nano /etc/letsencrypt/renewal-hooks/post/openlitespeed.sh

# Script content:
#!/bin/bash
systemctl reload openlitespeed

# Make executable:
sudo chmod +x /etc/letsencrypt/renewal-hooks/post/openlitespeed.sh

# Test renewal:
sudo certbot renew --dry-run

# Set automatic renewal:
# Cron job: certbot renew --quiet
# Runs daily via /etc/cron.d/certbot

Certificate Security

# Verify certificate validity:
openssl x509 -in /etc/letsencrypt/live/example.com/cert.pem -text -noout

# Check expiration:
openssl x509 -in /etc/letsencrypt/live/example.com/cert.pem -noout -dates

# Verify private key:
openssl rsa -in /etc/letsencrypt/live/example.com/privkey.pem -check

# Ensure proper permissions:
sudo chmod 644 /etc/letsencrypt/live/example.com/fullchain.pem
sudo chmod 600 /etc/letsencrypt/live/example.com/privkey.pem

Static File Handling

Optimizing Static Content

# Configure static context:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context

# Static file optimization:
# - URI: /static/
# - Location: /home/user/domains/example.com/static
# - Allowable Methods: GET, HEAD
# - Enable Expires: Yes
# - Expires Default: 1 year
# - No PHP processing

# This serves static files without PHP overhead
# Significantly improves performance

Compression

# Enable Gzip compression:

# Navigate WebConsole:
# Server Configuration > HTTP Compression

# Settings:
# - Enable Compression: Yes
# - Compression Level: 9 (maximum)
# - Compressible Types: text/*, application/json
# - Minimum File Size: 1024 bytes

# Compression benefits:
# - Reduces bandwidth usage
# - Improves load times
# - Server-side with browser decompression

# Verify compression:
curl -I -H "Accept-Encoding: gzip" http://example.com/style.css
# Check for: Content-Encoding: gzip

htaccess Conversion

Converting Apache Rules to OpenLiteSpeed

# Apache .htaccess format:
# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /
# RewriteRule ^index\.html$ - [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /index.php [L]
# </IfModule>

# OpenLiteSpeed equivalent (in WebConsole):
# Virtual Hosts > Context > Rewrite
# Paste the same rules directly
# OpenLiteSpeed understands Apache format

# Alternatively, use native OpenLiteSpeed format:
# static context with fallback to dynamic context

WordPress Rewrite Rules

# WordPress .htaccess:
# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /
# RewriteRule ^index\.php$ - [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /index.php [L]
# </IfModule>

# Configure in OpenLiteSpeed:
# Navigate: Virtual Hosts > WordPress Host > Context

# Create two contexts:
# 1. Static context:
#    - URI: /
#    - Match: Not !/index.php
#    - Allowable Methods: GET, HEAD

# 2. Dynamic context:
#    - URI: /index.php
#    - Handler: PHP 8.1

Security Hardening

Disabling Directory Listing

# Prevent directory browsing:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context

# Settings:
# - Enable Directory Index: Yes
# - Index Files: index.html index.php
# - Enable Static Directory Index: No

# This prevents listing when no index file exists

Restricting File Access

# Prevent access to sensitive files:

# Create static context for restrictions:
# - URI: /wp-config.php
# - Allowable Methods: (none)
# - Result: 404 Not Found

# Protect sensitive directories:
# - URI: /.git/
# - URI: /.env
# - Allowable Methods: (none)

Security Headers

# Configure HTTP security headers:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context > General

# Add headers:
# X-Frame-Options: SAMEORIGIN
# X-Content-Type-Options: nosniff
# X-XSS-Protection: 1; mode=block
# Strict-Transport-Security: max-age=31536000; includeSubDomains

# Example configuration:
# static context > General > Extra Headers:
# X-Frame-Options: SAMEORIGIN
# X-Content-Type-Options: nosniff

Disable Unnecessary Methods

# Limit HTTP methods:

# Navigate WebConsole:
# Virtual Hosts > Select Virtual Host > Context

# Static context:
# - Allowable Methods: GET, HEAD

# Dynamic context:
# - Allowable Methods: GET, POST, HEAD, OPTIONS

# This prevents unwanted PUT/DELETE/TRACE methods

Optimización del rendimiento

Worker Process Configuration

# Configure worker processes:

# Navigate WebConsole:
# Server Configuration > General

# Settings:
# - Max Connections: 10000
# - Max Idle Time: 300
# - Priority: -5 (higher priority)
# - Process Nice: -5

# These settings depend on hardware:
# - Server RAM
# - CPU cores
# - Expected traffic

# Example calculation:
# 8 GB RAM, 4 CPU cores:
# - Per-connection memory: 1-2 MB
# - Max connections: 4000-5000

Connection Pooling

# Optimize PHP connection pooling:

# Navigate WebConsole:
# Server Configuration > External App > PHP

# Settings:
# - Max Connections: 100-500 (adjust based on traffic)
# - Connection Timeout: 30 seconds
# - Response Timeout: 300 seconds

# Higher values = more resources, better performance
# Lower values = less resources, potential slowdowns

Buffer Configuration

# Optimize buffer sizes:

# Navigate WebConsole:
# Server Configuration > General

# Settings:
# - Static Buf Size: 64KB
# - SSL Session Cache Size: 10MB
# - Max Request URL Length: 8192
# - Max Request Header Size: 16KB

# These affect memory usage and performance

Supervisión and Logs

Real-Time Monitoring

# Monitor OpenLiteSpeed via WebConsole:
# Reports > Real-Time Statistics

# Available metrics:
# - Throughput (requests/sec)
# - Bandwidth (bytes/sec)
# - Connections
# - Cache hits
# - SSL connections
# - Requests by status code

# Monitor trends:
# - Peak request rates
# - Average response times
# - Cache effectiveness

Log Analysis

# View OpenLiteSpeed logs:

# Error log:
sudo tail -f /usr/local/lsws/logs/error.log

# Access log:
sudo tail -f /usr/local/lsws/logs/access.log

# Standard log format:
# remote_host - user [timestamp] "request_line" status_code bytes_sent

# Analyze logs:
# Top requested URLs:
awk '{print $7}' /usr/local/lsws/logs/access.log | sort | uniq -c | sort -rn | head

# Top status codes:
awk '{print $9}' /usr/local/lsws/logs/access.log | sort | uniq -c

# Top IPs:
awk '{print $1}' /usr/local/lsws/logs/access.log | sort | uniq -c | sort -rn | head

# Errors by type:
grep error /usr/local/lsws/logs/error.log | tail -20

Log Rotation

# Configure log rotation:

# Create logrotate configuration:
sudo nano /etc/logrotate.d/openlitespeed

# Content:
/usr/local/lsws/logs/*.log {
    daily
    rotate 14
    compress
    delaycompress
    notifempty
    create 0640 nobody nobody
    sharedscripts
    postrotate
        /usr/local/lsws/bin/lshttpd -t > /dev/null && /usr/local/lsws/bin/lshttpd -r
    endscript
}

# Test configuration:
sudo logrotate -d /etc/logrotate.d/openlitespeed

# Verify rotation:
ls -la /usr/local/lsws/logs/

Solución de problemas

Common Issues

# OpenLiteSpeed won't start:
sudo systemctl start openlitespeed
sudo journalctl -u openlitespeed -f

# Check configuration syntax:
/usr/local/lsws/bin/lshttpd -t

# View startup errors:
sudo /usr/local/lsws/bin/lshttpd -d -f /usr/local/lsws/conf/httpd_config.conf

# Website not displaying:
# Check virtual host configuration
# Check listener configuration
# Verify document root permissions
# Check PHP handler configuration

# PHP not executing:
# Verify PHP handler is configured
# Check PHP handler address/socket
# Test PHP directly: /usr/local/lsws/lsphp81/bin/php -v

# SSL certificate issues:
# Verify certificate path is correct
# Check file permissions
# Test certificate validity
# Verify private key matches certificate

# Port already in use:
sudo lsof -i :8080
sudo kill -9 PID

# Permission denied errors:
# Check file ownership: sudo chown nobody:nobody /home/user/domains/
# Check permissions: sudo chmod 755 /home/user/domains/

Performance Diagnosis

# Monitor resource usage:
top -p $(pgrep -f lshttpd)

# Check network connections:
netstat -an | grep ESTABLISHED | wc -l

# Monitor disk I/O:
iotop -b -o -n 1 | grep lshttpd

# Check cache effectiveness:
# WebConsole > Reports > Cache Statistics
# Monitor hit ratio and evictions

# Analyze PHP performance:
# WebConsole > Reports > Real-Time Statistics
# Check PHP request processing time

# Database query optimization:
# Enable query logging in application
# Analyze slow queries
# Add indexes where needed

Conclusión

OpenLiteSpeed provides a modern, high-rendimiento web server alternative that delivers exceptional speed and efficiency without sacrificing functionality. With native PHP support, advanced caching, comprehensive seguridad features, and intuitive management interface, OpenLiteSpeed scales from single websites to high-traffic hosting environments.

By implementing the installation procedures, configuration best practices, and rendimiento optimization techniques outlined in this guide, you establish a reliable, fast web hosting platform. Regular monitoreo, log analysis, and seguridad updates ensure your OpenLiteSpeed implementación remains performant and secure.

Whether migrating from Apache/Nginx or building new infrastructure, OpenLiteSpeed delivers the rendimiento and confiabilidad expected by modern web applications and hosting providers.