Installing an SSL certificate on a VPS secures your website with HTTPS, ensuring encrypted data transfer and user trust. This guide covers setting up a free Let’s Encrypt SSL certificate on a Linux VPS with Nginx, incorporating VPS.DO elements for context.
Prerequisites
- A VPS with root access (e.g., VPS.DO’s 1H2G plan with Ubuntu 20.04/22.04).
- A domain name pointed to your VPS IP.
- Nginx installed and a website configured.
- Basic SSH knowledge.
Step-by-Step Installation
1. Connect to Your VPS
Access your VPS via SSH using credentials from VPS.DO’s SolusVM control panel:
ssh root@your_vps_ip
2. Install Certbot
Certbot automates Let’s Encrypt SSL certificate issuance. Install it:
sudo apt update sudo apt install certbot python3-certbot-nginx -y # Ubuntu/Debian sudo yum install certbot python3-certbot-nginx -y # CentOS
3. Obtain the SSL Certificate
Run Certbot to obtain and install the certificate for your domain:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Follow the prompts:
- Enter an email for renewal notifications.
- Agree to terms and select options for HTTP-to-HTTPS redirection.
Certbot automatically configures Nginx to use the SSL certificate.
4. Verify Nginx Configuration
Check the Nginx configuration for SSL settings:
sudo nano /etc/nginx/sites-available/yourdomain.com
Ensure it includes:
listen 443 ssl; ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
Test and reload Nginx:
sudo nginx -t sudo systemctl reload nginx
5. Test the SSL Installation
Visit https://yourdomain.com to confirm the site loads with a secure lock icon. Use an SSL checker (e.g., sslshopper.com) to verify.
6. Automate Renewal
Let’s Encrypt certificates expire every 90 days. Certbot sets up automatic renewal. Test it:
sudo certbot renew --dry-run
Ensure the cron job is active:
sudo systemctl status certbot.timer
7. Secure and Monitor
- Firewall: Allow HTTPS traffic:
sudo ufw allow 443/tcp sudo ufw enable
- Monitor Resources: Use VPS.DO’s SolusVM panel to track CPU and RAM usage, ensuring SSL operations don’t overload your VPS.
- Backup Certificates: Back up /etc/letsencrypt to a secure location.
Conclusion
Installing an SSL certificate with Let’s Encrypt and Certbot is straightforward, securing your VPS-hosted website. VPS.DO’s full root access and NVMe SSDs support fast and reliable SSL setup. Regularly verify renewals and monitor server performance for optimal security.