Key takeaways
- Certbot obtains, installs and renews Let's Encrypt certificates automatically.
- DNS must point at the server before you request a certificate.
- Certificates last 90 days; renewal runs on a timer.
Before you start
- Your domain’s
Arecords (bothexample.comandwww) point to the server. - Ports 80 and 443 are open:
sudo ufw allow 'Nginx Full'orsudo ufw allow 'Apache Full'. - The web server has a site configured for the domain.
1. Install Certbot
The Certbot project recommends the snap package:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
2. Request and install the certificate
For Nginx:
sudo certbot --nginx -d example.com -d www.example.com
For Apache, use --apache instead. Enter an email for expiry notices and agree to the terms. Certbot edits your configuration and sets up the HTTP-to-HTTPS redirect.
3. Confirm renewal works
sudo certbot renew --dry-run
systemctl list-timers | grep certbot
4. Verify
Run the SSL checker on your domain. It should show a valid certificate, the full chain and TLS 1.2/1.3.
Frequently asked questions
Why does Certbot fail with a challenge error?
Let's Encrypt couldn't reach your server over HTTP on port 80 for that hostname. Check the A record, open port 80 in the firewall, and make sure no CDN or redirect is interfering.
Can I get a wildcard certificate?
Yes, but wildcards require the DNS-01 challenge, which means adding a TXT record — manually or with a DNS provider plugin.