Security

Let's Encrypt on Apache (Ubuntu 24.04 and 22.04): Free HTTPS

Running Apache instead of Nginx? Certbot's Apache plugin gets a free certificate, edits your virtual host for HTTPS and sets up automatic renewal.

Full guide: Full Let's Encrypt guide

1. Install Certbot and the Apache plugin

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

2. Check your virtual host

ServerName (and ServerAlias) must match the domains, and DNS must point at this server.

sudo apachectl -S
sudo apachectl configtest

3. Open the firewall

Port 80 must stay open for validation and renewal.

sudo ufw allow 'Apache Full'

4. Get the certificate

Certbot creates an SSL virtual host (example.com-le-ssl.conf) and can add the HTTP to HTTPS redirect.

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

5. Verify

You should see the new certificate and a working renewal.

sudo certbot certificates
sudo certbot renew --dry-run
curl -I https://example.com

6. Troubleshooting

Unable to find a virtual host: add ServerName to the vhost, reload Apache, run Certbot again. Challenge failed: check DNS, port 80 and that no rewrite rule blocks /.well-known/acme-challenge/.

sudo tail -n 50 /var/log/letsencrypt/letsencrypt.log

FAQ

Is Let's Encrypt free?

Yes. It is a free, nonprofit certificate authority trusted by all major browsers.

Where does Certbot put the Apache SSL config?

In a new file next to your site config, usually /etc/apache2/sites-available/example.com-le-ssl.conf, enabled automatically.

Further reading: Certbot user guide