How to Set Up Let's Encrypt SSL on AlmaLinux/Rocky Linux

This guide covers installing Certbot and obtaining free Let's Encrypt SSL certificates on AlmaLinux/Rocky Linux, for both Nginx and httpd (Apache).

Prerequisites

  • AlmaLinux 9 or Rocky Linux 9 VPS
  • Nginx or httpd already installed and serving your domain over HTTP
  • A domain with DNS pointing to your VPS

Step 1 — Enable EPEL

sudo dnf install epel-release -y

Step 2 — Install Certbot

For Nginx:

sudo dnf install certbot python3-certbot-nginx -y

For httpd:

sudo dnf install certbot python3-certbot-apache -y

Step 3 — Allow HTTP/HTTPS Through firewalld

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Step 4 — Confirm DNS Points to This Server

dig +short yourdomain.com

Step 5 — Request and Install the Certificate

For Nginx:

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

For httpd:

sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

Step 6 — Verify HTTPS

https://yourdomain.com

Step 7 — Test Automatic Renewal

sudo certbot renew --dry-run

Step 8 — Verify the Renewal Timer Is Active

sudo systemctl list-timers | grep certbot

Certbot's RPM package on AlmaLinux/Rocky Linux typically installs a systemd timer for automatic renewal, similar to the Ubuntu/Debian package.

SELinux Considerations

Certificate files under /etc/letsencrypt/ generally receive the correct SELinux context automatically when Certbot's Nginx/Apache plugin configures them. If you manually reference certificate paths in a custom configuration and encounter permission issues:

sudo ausearch -m avc -ts recent | grep nginx

Manually Configuring a Certificate (If Not Using the Plugin)

sudo certbot certonly --nginx -d yourdomain.com

Then reference the certificate paths manually in your server block:

ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

Common Errors

"Could not bind to port 80" — confirm the firewalld rule for HTTP was added and no other service is already using the port.

Challenge fails — verify DNS actually resolves to this server's IP, and that firewalld permits inbound port 80 traffic from the internet.

Renewal fails silently — check the systemd timer status and Certbot's own logs:

sudo journalctl -u certbot-renew.timer

Best Practices

  • Always confirm certbot renew --dry-run succeeds right after initial setup
  • Ensure firewalld allows both HTTP (for renewal challenges) and HTTPS permanently, not just during initial setup
  • Follow the same renewal monitoring practices covered in How to Renew and Auto-Renew Let's Encrypt Certificates

Continue Reading

Browse more articles in AlmaLinux & Rocky Linux.

  • lets encrypt almalinux, certbot rocky linux, rhel ssl, firewalld certbot
  • 0 Usuários acharam útil
Esta resposta lhe foi útil?

Artigos Relacionados

AlmaLinux vs Rocky Linux vs CentOS: What Happened to CentOS?

If you're choosing a RHEL-compatible Linux distribution for your VPS, understanding the CentOS...

How to Get Started with AlmaLinux/Rocky Linux on a VPS

This guide covers the essential first steps after deploying a new AlmaLinux or Rocky Linux VPS...

How to Use dnf: The Package Manager for AlmaLinux & Rocky Linux

dnf (Dandified YUM) is the package manager for AlmaLinux, Rocky Linux, and other RHEL-family...

How to Configure firewalld on AlmaLinux/Rocky Linux

firewalld is the default firewall management tool on AlmaLinux and Rocky Linux, using a...

How to Install Nginx on AlmaLinux/Rocky Linux

This guide covers installing and configuring Nginx on AlmaLinux or Rocky Linux, including the...