Yazı Boyutu:

Introduction

To ensure secure communication over the internet, SSL (Secure Sockets Layer), now more accurately referred to as TLS (Transport Layer Security), is a must-have for any web server. In this article, we'll walk you through how to install and configure a free Let's Encrypt SSL certificate on AlmaLinux 8, using popular web servers such as Apache and Nginx.


1. Prerequisites

  • A running server with AlmaLinux 8

  • A valid domain name (e.g., example.com)

  • The domain must point to your server's IP address

  • Root or sudo access


2. Install Certbot (Let's Encrypt Client)

Step 1: Install EPEL and Certbot packages

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

For Nginx users, install this instead:

dnf install python3-certbot-nginx -y

3. SSL Setup for Apache

Step 1: Make sure Apache is installed and running

systemctl status httpd

Step 2: Obtain the SSL certificate

certbot --apache

Certbot will ask for your domain and email, then automatically configure Apache for HTTPS.

Step 3: Automate SSL renewal

echo "0 0 * * * root certbot renew --quiet" >> /etc/crontab

4. SSL Setup for Nginx

Step 1: Make sure Nginx is installed

systemctl status nginx

Step 2: Obtain the SSL certificate

certbot --nginx

Certbot will detect your Nginx configuration and apply the necessary changes.


5. Manual SSL Configuration (Optional)

Let's Encrypt certificates are typically stored here:

  • Certificate: /etc/letsencrypt/live/example.com/fullchain.pem

  • Private key: /etc/letsencrypt/live/example.com/privkey.pem

Apache Manual Configuration

Edit /etc/httpd/conf.d/ssl.conf or your custom virtual host file:

<VirtualHost *:443> ServerName example.com DocumentRoot /var/www/html SSLEngine on SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem </VirtualHost>

Nginx Manual Configuration

server { listen 443 ssl; server_name example.com; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; location / { root /usr/share/nginx/html; index index.html; } }

6. Redirect HTTP to HTTPS

Apache

<VirtualHost *:80> ServerName example.com Redirect permanent / https://example.com/ </VirtualHost>

Nginx

server { listen 80; server_name example.com; return 301 https://$host$request_uri; }

7. Check SSL Certificate Status

certbot certificates

This shows active certificates and their expiration dates.


Conclusion

Setting up SSL on AlmaLinux 8 is straightforward, especially with Let's Encrypt and Certbot. With these steps, you can secure your website with HTTPS and protect your users’ data.