Avantguard Computer & Security Systems

Let's Encrypt (Certbot)

Apache + SSL + Certbot in 5 Steps

Step 1: Install Apache

apt update
apt install apache2
systemctl enable apache2
systemctl start apache2

Step 2: Enable Required Modules

a2enmod ssl
a2enmod rewrite
systemctl restart apache2

Step 3: Create VirtualHost

# /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/html/example.com

    <Directory /var/www/html/example.com>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
a2ensite example.com.conf
systemctl reload apache2

Step 4: Install Certbot

apt install certbot python3-certbot-apache

Step 5: Obtain Certificate

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

Certbot will:

  1. Verify domain ownership via HTTP challenge
  2. Obtain certificate from Let’s Encrypt
  3. Automatically configure Apache for HTTPS
  4. Set up auto-renewal

Auto-Renewal

Certbot installs a systemd timer. Verify it:

systemctl status certbot.timer
certbot renew --dry-run

Certificates renew automatically when they are within 30 days of expiry.