How to Get Free HTTPS with Let’s Encrypt and Certbot

Security 3 min readUpdated Oct 29, 2026
6 views0 comments

HTTPS is no longer optional: browsers warn about plain HTTP sites and search engines prefer HTTPS. Let’s Encrypt gives you trusted certificates for free, and Certbot automates getting and renewing them. This guide covers Apache and Nginx on a Linux server.

Before you start

  • Your domain’s DNS A record (and AAAA if you use IPv6) must point to this server. Check with dig +short example.com.
  • Ports 80 and 443 must be open in the firewall, because Let’s Encrypt validates by visiting your site on port 80.
  • A working HTTP site for the domain, in Apache or Nginx.

Step 1: Install Certbot

Debian / Ubuntu, with the packages from the distribution:

sudo apt update
sudo apt install certbot python3-certbot-apache    # Apache
sudo apt install certbot python3-certbot-nginx     # Nginx

AlmaLinux / Rocky / RHEL (enable the EPEL repository first):

sudo dnf install epel-release
sudo dnf install certbot python3-certbot-apache    # or python3-certbot-nginx

The Certbot project also offers a snap package (sudo snap install --classic certbot), which is kept up to date automatically. Either way works.

Step 2: Get and install the certificate

sudo certbot --apache -d example.com -d www.example.com
# or
sudo certbot --nginx  -d example.com -d www.example.com

Certbot asks for your email address (used for expiry warnings), checks that you control the domain, edits your web server configuration and offers to redirect HTTP to HTTPS. Say yes. Open your site with https:// and look for the padlock.

Step 3: Confirm automatic renewal

Certificates are valid for 90 days, and Certbot renews them well before that through a systemd timer or a cron job. Verify the timer exists and run a safe test:

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

If the dry run ends with “all simulated renewals succeeded”, you are done. Renewals need port 80 to stay reachable.

Where things are stored

/etc/letsencrypt/live/example.com/fullchain.pem   # certificate (use this one)
/etc/letsencrypt/live/example.com/privkey.pem     # private key (keep secret)

Never copy the private key into a repository or send it by email.

Check the result from outside

curl -I https://example.com
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates -issuer

The second command prints the validity dates and the issuer.

Common problems

Error Cause and fix
“Timeout during connect” or “Connection refused” Port 80 is blocked or the DNS record points elsewhere. Open the port and check DNS.
“Invalid response” / 404 on the challenge Another site answers for that name. Make sure the domain’s virtual host exists and is enabled.
“too many certificates already issued” You hit a rate limit. Wait a few days and use --dry-run while testing, which does not count.
Renewal works by hand but not automatically The timer is disabled, or the web server needs a reload hook. Check systemctl status certbot.timer.

Other options worth knowing

  • Webroot mode if you do not want Certbot to edit configuration: sudo certbot certonly --webroot -w /var/www/html -d example.com, then point the web server at the certificate files yourself.
  • Wildcard certificates (*.example.com) need DNS validation, which means adding a TXT record, so they are best automated through your DNS provider’s plugin.
  • Mail servers can use the same certificates. Reload them after each renewal with a deploy hook placed in /etc/letsencrypt/renewal-hooks/deploy/.
Did you find this helpful?Tap the heart to let us know. It takes one second and no account.

More tutorials like this

Leave a Comment

Your email address will not be published. Required fields are marked *

Bigland Network IT

Practical tutorials for people who run, build and fix things: operating systems, databases, development, networking and security.

Topics

More

Site

© 2026 Bigland Network. All rights reserved.Always test commands on a non-production system first.
Scroll to Top