Setting Up Let's Encrypt SSL Certificates
Let's Encrypt provides free, trusted SSL certificates. Certbot automates the process of obtaining and renewing them.
Prerequisites
- A domain name pointed to your server's IP address
- Ports 80 and 443 open in your firewall
Install Certbot for Nginx
apt install certbot python3-certbot-nginx -y
Obtain a Certificate (Nginx)
certbot --nginx -d yourdomain.com -d www.yourdomain.com
Install Certbot for Apache
apt install certbot python3-certbot-apache -y
certbot --apache -d yourdomain.com
Standalone Mode (No Web Server Running)
certbot certonly --standalone -d yourdomain.com
Test Auto-Renewal
certbot renew --dry-run
Certbot automatically installs a cron job to renew certificates before they expire (certificates are valid for 90 days).
Manual Renewal
certbot renew
View Installed Certificates
certbot certificates