LiteSpeed Web Server is a powerful and performance-driven alternative to traditional web servers like Apache or Nginx. Securing your website with HTTPS via a free Let’s Encrypt SSL certificate not only protects user data but also boosts SEO. Below is a detailed guide for installing SSL and syncing site files efficiently.
Table of Contents
Step 1: Update System Packages
sudo apt update
This command ensures your system’s package list is up to date so you can install the latest software packages and dependencies without issues.
Step 2: Install Certbot (Let’s Encrypt Client)
sudo apt install certbot
Certbot is the recommended tool by Let’s Encrypt for automatically generating and renewing SSL certificates.
Step 3: Generate SSL Certificate
sudo certbot certonly --webroot -w /usr/local/lsws/example.com/html/ -d example.com -d www.example.com
This command issues a certificate for your domain using the webroot
plugin. Replace /usr/local/lsws/example.com/html/
with your actual web root directory. Ensure DNS is pointed correctly to your server before running this.
✅ After success, your certificate and key will be stored in:
- Certificate:
/etc/letsencrypt/live/example.com/fullchain.pem
- Private Key:
/etc/letsencrypt/live/example.com/privkey.pem
These will be used inside LiteSpeed’s SSL settings.
Step 4: Auto-Renew SSL with Cron
Edit the root user’s crontab to schedule monthly renewals:
sudo crontab -e
Add the following lines:
30 2 7 * * certbot renew --force-renewal
00 3 7 * * /usr/local/lsws/bin/lswsctrl reload
Explanation:
- 2:30 AM on the 7th of every month: Triggers certificate renewal.
- 3:00 AM on the 7th: Reloads the LiteSpeed server to apply the renewed certificate.