Skip to content
Log In Sign Up info@muvcloud.com

The Short Version

On Ubuntu or Debian, with Apache already serving the site over HTTP:

sudo apt update
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d example.com -d www.example.com --email YOUR_EMAIL

Certbot asks you to accept the Let's Encrypt terms on the first run, validates the names over port 80, writes an HTTPS virtual host, and reloads Apache. Read on for what must be ready first, the AlmaLinux and Rocky Linux steps, and the renewal check.

Set ServerName in the Virtual Host

Certbot matches the names you request against ServerName and ServerAlias. A virtual host without them is the most common reason the plugin cannot decide where to install the certificate.

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
</VirtualHost>

On Ubuntu and Debian the file goes in /etc/apache2/sites-available/example.com.conf. Enable it and test:

sudo a2ensite example.com.conf
sudo apachectl configtest
sudo systemctl reload apache2

On AlmaLinux and Rocky Linux the file goes in /etc/httpd/conf.d/example.com.conf, and the service is called httpd.

Check DNS and Port 80

  • DNS: the A record, and the AAAA record if there is one, for every name must point to this server. Let's Encrypt prefers IPv6 when an AAAA record exists.
  • Port 80: the HTTP-01 challenge comes in on port 80. Open 80 and 443 with sudo ufw allow 80/tcp and sudo ufw allow 443/tcp, or with sudo firewall-cmd --permanent --add-service=http --add-service=https followed by sudo firewall-cmd --reload.
  • Provider firewall: if your provider's control panel has one, open the same ports there.

AlmaLinux and Rocky Linux: mod_ssl and EPEL

Apache on the RHEL family has no TLS support until mod_ssl is installed. Certbot itself comes from EPEL:

sudo dnf install mod_ssl
sudo dnf install epel-release
sudo dnf install certbot python3-certbot-apache
sudo systemctl restart httpd

mod_ssl adds /etc/httpd/conf.d/ssl.conf with a default HTTPS site that uses a self-signed certificate. Leave it in place; Certbot creates a separate virtual host for your names. On Ubuntu and Debian, mod_ssl ships with Apache and Certbot enables it when needed; to do it by hand, run sudo a2enmod ssl and reload Apache.

Choose the Redirect

Current Certbot releases add a redirect from HTTP to HTTPS by default and no longer ask. Add --no-redirect to keep port 80 serving the site, or --redirect to state the default explicitly. The redirect is written as rewrite rules into the port 80 virtual host. Keep only one redirect: if your application or an .htaccess file already redirects, two rules can fight and produce ERR_TOO_MANY_REDIRECTS.

What Certbot Changes

Certbot writes a new file next to your original virtual host, usually with -le-ssl.conf at the end of its name, containing a *:443 virtual host with these lines:

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

Edit your own settings in that virtual host if you need to, but never edit or delete the files under /etc/letsencrypt by hand. To remove a certificate, take it out of the Apache configuration first, then run sudo certbot delete --cert-name example.com.

Check Renewal

Let's Encrypt certificates are valid for 90 days today, with shorter lifetimes announced from February 2027, and Let's Encrypt no longer sends reminder e-mails. Confirm that a timer exists and that a test renewal passes:

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

The apt package and the snap start their timer on installation. On AlmaLinux and Rocky Linux, if no timer is listed, switch on the EPEL one with sudo systemctl enable --now certbot-renew.timer. The Apache plugin reloads Apache after each renewal. More detail is in how to renew Let's Encrypt certificates.

Common Problems

  • No virtual host found for a name: add it to ServerName or ServerAlias, test with sudo apachectl configtest, and reload.
  • Timeout during validation: port 80 is blocked, or DNS points to another server.
  • Apache does not start after the change: run sudo apachectl configtest and read the line it names; the error log is /var/log/apache2/error.log or /var/log/httpd/error_log.
  • Browser still shows the old certificate: another virtual host answers on port 443 for that name. Compare with the steps in NET::ERR_CERT_COMMON_NAME_INVALID.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations