Securing Apache2 with Let’s Encrypt SSL Certificates

Let’s Encrypt made free, automated SSL certificates standard practice — there’s no longer a good reason to run any public Apache site over plain HTTP.

sudo apt install certbot python3-certbot-apache

# Certbot automatically edits your Apache config, obtains a cert, and sets up HTTPS
sudo certbot --apache -d example.com -d www.example.com

# Certificates auto-renew via a systemd timer or cron job installed by certbot
sudo certbot renew --dry-run   # test that renewal actually works
<VirtualHost *:443>
    ServerName example.com
    DocumentRoot /var/www/example.com/public
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

# Certbot also adds an automatic HTTP -> HTTPS redirect for port 80

Let’s Encrypt certificates are valid for 90 days, deliberately short to encourage automation rather than manual renewal — the certbot-installed auto-renewal timer is what makes this genuinely maintenance-free once set up correctly.