Skip to main content

Configuration Testing

Learning Focus

By the end of this lesson you will know how to validate OpenLiteSpeed configuration before reloading, catch common syntax and path errors, and build a pre-reload checklist.

Why Test Before Reloading

Most configuration incidents come from small mismatches that simple validation could catch. A missing file path, a wrong permission, or a broken external app reference can take a production site down during a reload.

Pre-Reload Checklist

Run through this checklist before every reload:

CheckCommand / ActionWhat to Look For
Config syntaxReview WebAdmin for save errorsRed warnings or error banners
File paths existls -la /path/to/cert.pemFile not found errors
Permissions correctstat /usr/local/lsws/conf/httpd_config.confOwnership by lsadm or nobody
External app reachablels -la /usr/local/lsws/lsphp84/bin/lsphpBinary exists and is executable
Certificate validopenssl x509 -in cert.pem -noout -datesNot expired, correct hostname
Document root existsls -la /var/www/example.com/public/Directory exists with correct permissions

Validating Config File Syntax

OpenLiteSpeed does not have a standalone configtest command like Apache. Instead, use these methods:

Method 1: WebAdmin Save Validation

When you save changes through WebAdmin, it performs basic validation. If there are syntax errors, the save dialog shows warnings.

Method 2: Check Logs After Reload

# Perform a graceful reload
sudo /usr/local/lsws/bin/lswsctrl restart

# Immediately check the error log
tail -50 /usr/local/lsws/logs/error.log

Look for lines containing [ERROR], [WARNING], or failed to patterns.

Method 3: Manual File Review

# Inspect the main config
cat /usr/local/lsws/conf/httpd_config.conf | head -100

# Inspect a virtual host config
cat /usr/local/lsws/conf/vhosts/example/vhconf.conf

Common Config Errors and How to Spot Them

ErrorSymptomHow to Check
Wrong certificate pathSSL listener fails, 525 errorsls -la /path/to/cert.pem /path/to/key.pem
Missing document root404 or 403 for all pagesls -la $VH_ROOT/html/
Wrong lsphp binary path503 errors on PHP pagesls -la /usr/local/lsws/lsphp84/bin/lsphp
Permission denied on socketPHP connection refusedls -la /tmp/lshttpd/
Domain not mapped to vhostDefault page shown insteadCheck listener → virtual host mapping in WebAdmin

Building a Testing Habit

pre-reload-check.sh
#!/bin/bash
# Quick pre-reload validation script

echo "=== Checking OpenLiteSpeed config ==="

# Check main config file exists
if [ ! -f /usr/local/lsws/conf/httpd_config.conf ]; then
echo "ERROR: Main config file missing!"
exit 1
fi

# Check lsphp binary
if [ ! -x /usr/local/lsws/lsphp84/bin/lsphp ]; then
echo "WARNING: lsphp84 binary not found or not executable"
fi

# Check certificate files (adjust paths)
for cert in /etc/ssl/private/*.pem; do
if [ -f "$cert" ]; then
openssl x509 -in "$cert" -noout -checkend 86400 2>/dev/null
if [ $? -ne 0 ]; then
echo "WARNING: Certificate $cert expires within 24 hours"
fi
fi
done

# Check log permissions
if [ ! -w /usr/local/lsws/logs/ ]; then
echo "WARNING: Log directory not writable"
fi

echo "=== Checks complete ==="
warning

Do not skip validation even for small changes. A single-character typo in a path can cause site-wide outages.

Key Takeaways

  • Most config incidents come from small mismatches that simple validation could catch.
  • Use WebAdmin save validation, log checks, and manual file review as your testing layers.
  • Build a pre-reload checklist and make it a habit before every change.
  • Document your config paths so you can validate them quickly under pressure.

What's Next

  • Continue to Common Errors to learn how to diagnose 403, 500, and permission issues.