Knowledgebase

How to install a free Let's Encrypt SSL with Certbot on a VPS

A free SSL certificate from Let's Encrypt makes your site load over HTTPS and removes the "Not secure" warning. On a VPS without a control panel, the easiest way to get one is Certbot. This guide shows how to install a free Let's Encrypt SSL with Certbot on an AlmaLinux VPS running Nginx or Apache, and how to make sure it renews automatically.

Using cPanel? You do not need Certbot. cPanel and WHM issue free certificates automatically with AutoSSL. See How to get a free SSL certificate for your website (AutoSSL).

Before you start

  • Your domain (and www if you use it) must already point to the server IP. Check with ping example.com, or read How to point your domain to your hosting.
  • Ports 80 and 443 must be open in the firewall: sudo firewall-cmd --permanent --add-service=http --add-service=https && sudo firewall-cmd --reload.
  • Your web server must already serve the site over HTTP, with a server block or virtual host whose server_name/ServerName matches the domain.

Step 1: Install Certbot

Certbot comes from the EPEL repository. For Nginx:

sudo dnf install -y epel-release
sudo dnf install -y certbot python3-certbot-nginx

For Apache:

sudo dnf install -y epel-release
sudo dnf install -y certbot python3-certbot-apache mod_ssl

Step 2: Get the certificate

  1. Run Certbot with the plugin for your web server and list every name you want on the certificate:
sudo certbot --nginx -d example.com -d www.example.com
# or, for Apache:
sudo certbot --apache -d example.com -d www.example.com
  1. Enter your email address (Let's Encrypt uses it for important notices) and accept the terms.
  2. Certbot proves you own the domain, installs the certificate and edits your Nginx/Apache configuration to use it. Recent versions also add a redirect from HTTP to HTTPS.
  3. Open https://example.com and check the padlock in the browser.

Step 3: Make sure renewal is automatic

Let's Encrypt certificates are valid for 90 days. Enable the renewal timer and test it once:

sudo systemctl enable --now certbot-renew.timer
sudo systemctl list-timers | grep certbot
sudo certbot renew --dry-run

If the dry run succeeds, the certificate will renew by itself before it expires. To see your certificates and their expiry dates:

sudo certbot certificates

Tips

  • A wildcard certificate (*.example.com) needs a DNS challenge (a TXT record) instead of the web server plugin.
  • If your site is behind Cloudflare with the proxy (orange cloud) on, set the SSL mode to Full (strict) after you install the certificate.
  • Do not request certificates again and again while testing; Let's Encrypt has rate limits. Use --dry-run or --staging for tests.

Common problems

  • "Challenge failed" or "Timeout during connect": the domain does not point to this server yet, or port 80 is closed. Check DNS and the firewall.
  • "Could not find a matching server block": add server_name example.com www.example.com; to your Nginx config, reload, and run Certbot again.
  • The site still shows the old certificate: reload the web server with sudo systemctl reload nginx (or httpd).
  • Renewal fails months later: usually a firewall or DNS change. Run sudo certbot renew --dry-run to see the exact error.

Frequently asked questions

Is a free Let's Encrypt certificate as secure as a paid one?

The encryption is the same. Paid certificates can add organization validation, a warranty or support, which some businesses need.

Can I use Certbot with a Node.js app or Docker?

Yes. Put Nginx in front of the app as a reverse proxy and run Certbot with the Nginx plugin.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • SSL, Let's Encrypt, Certbot, HTTPS, VPS, Nginx, Apache

Was this answer helpful?

0 Users Found This Useful