Let's Encrypt with Apache

With certbot and the Apache plugin, HTTPS is set up in minutes: certbot gets the certificate, adds it to the vhost and renews it on its own afterwards. Here is what you need and what can go wrong.

Requirements

Install certbot

# Debian, Ubuntu
sudo apt install certbot python3-certbot-apache

# RHEL, Rocky, Alma (from EPEL)
sudo dnf install epel-release
sudo dnf install certbot python3-certbot-apache

# alternative, always up to date
sudo snap install --classic certbot

Obtain and install the certificate

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

On the first run certbot asks for an email address and the terms of service. It then creates a vhost for port 443 (on Debian …-le-ssl.conf), adds certificate and key, and sets up the redirect from HTTP to HTTPS if you want (--redirect). Since version 2.0 certbot creates ECDSA keys; for very old clients there is --key-type rsa.

If certbot should not touch the Apache configuration, certonly only obtains the certificate:

sudo certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com

The files are then in /etc/letsencrypt/live/example.com/. How to add them to the vhost yourself is in the article set up SSL/TLS in Apache. Use fullchain.pem, not cert.pem.

Automatic renewal

Certificates are valid for 90 days. The packages set up a systemd timer that checks twice a day and renews from 30 days remaining. Check:

systemctl list-timers | grep certbot
sudo certbot renew --dry-run

With the Apache plugin certbot reloads Apache itself after renewal. With certonly --webroot you need a deploy hook, otherwise Apache keeps serving the old certificate:

sudo certbot renew --deploy-hook "systemctl reload apache2"
# permanently: put a script into /etc/letsencrypt/renewal-hooks/deploy/

Let's Encrypt has not sent reminder emails since 2025. To notice a failure, add the server to the certificate expiry overview or embed the expiry badge from the SSL check.

Wildcard certificates

*.example.com is only available with DNS validation (DNS-01). certbot needs a plugin for your DNS provider, e.g. python3-certbot-dns-cloudflare, or you use acme.sh, which supports very many providers. --manual works without a plugin but does not renew automatically. The ACME helper generates the commands for your provider.

Typical errors

Finally check chain and protocols with the SSL check.

FAQ

Is Let's Encrypt really free?

Yes. Let's Encrypt is a non-profit CA. The certificates are equivalent to purchased domain-validated certificates and accepted by all browsers.

Does it work at a web host without root access?

Almost all hosts let you enable Let's Encrypt with one click in the control panel, e.g. in Plesk or cPanel. You only need certbot on your own servers.

Can I put several domains in one certificate?

Yes, with several -d options, up to 100 names. For independent sites, separate certificates are easier to manage.

Sources and documentation