Managing litespeed effectively is a crucial skill for any system administrator. This tutorial provides step-by-step instructions for ubuntu configuration, along with best practices for production environments.
Prerequisites
- A registered domain name (for public-facing services)
- Basic familiarity with the Linux command line
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- SSL certificate or Certbot for Let's Encrypt
Server Installation
Security should be a primary consideration when configuring litespeed. Always use strong passwords, keep software updated, and restrict network access to only the necessary ports and IP addresses.
# /etc/nginx/sites-available/litespeed.conf
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.
Virtual Host Configuration
It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.
# Test and reload Nginx configuration
sudo nginx -t
sudo systemctl reload nginx
# Check access and error logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.
- Keep your system packages updated regularly
- Test your backup restore procedure monthly
- Review log files weekly for anomalies
SSL/TLS Setup
For production deployments, consider implementing high availability by running multiple instances behind a load balancer. This approach provides both redundancy and improved performance under heavy load.
# Install Nginx with modules
sudo apt update
sudo apt install -y nginx
# Enable the site
sudo ln -s /etc/nginx/sites-available/litespeed.conf /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo systemctl restart nginx
Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.
Performance Tuning
After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.
# /etc/nginx/sites-available/litespeed.conf
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
Wrapping Up
Following this guide, your litespeed setup should be production-ready. Keep an eye on resource usage as your traffic grows and don't forget to test your backup and recovery procedures periodically.