Install SSL Certificate in Debian

This guide shows you how to install and configure free Let's Encrypt SSL/TLS certificates on Debian 13 (Trixie) and Debian 12 (Bookworm) web servers using Certbot.

Prerequisites

Step 1: Install Certbot

For Apache:

sudo apt update
sudo apt install -y certbot python3-certbot-apache

For Nginx:

sudo apt update
sudo apt install -y certbot python3-certbot-nginx

Step 2: Obtain SSL Certificate

For Apache

sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

For Nginx

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

During setup:

Step 3: Verify Installation & Test Security

Verify that Certbot issued and tracks your certificate:

sudo certbot certificates

Visit your website with https:// to confirm it loads cleanly, then run post-install checks with:

Step 4: Verify Auto-Renewal

Certbot automatically creates a systemd timer (certbot.timer) for renewal. Test the renewal process with a dry run:

sudo certbot renew --dry-run

Check the renewal timer status:

sudo systemctl status certbot.timer

Troubleshooting

Certificate Not Renewing Automatically

Trigger a manual renewal test or check the timer logs:

sudo certbot renew

Check renewal logs:

sudo tail -f /var/log/letsencrypt/letsencrypt.log

Port 80 or 443 Not Accessible

Ensure your UFW firewall allows both HTTP (for ACME HTTP-01 validation) and HTTPS traffic:

sudo ufw allow 80,443/tcp

(Alternatively, you can use UFW application profiles such as sudo ufw allow 'Apache Full' or sudo ufw allow 'Nginx Full' if installed.)

Domain Not Resolving

Verify your DNS records resolve to your server's public IP address:

dig yourdomain.com +short

Additional Resources

User