Step 1: Install Apache and mod_ssl
First, ensure that Apache and the mod_ssl
module are installed to enable HTTPS support:
sudo yum install -y httpd mod_ssl
Start Apache and enable it to run on boot:
sudo systemctl start httpd sudo systemctl enable httpd
Step 2: Install Certbot
Certbot is the tool that will help you automatically obtain and manage SSL certificates from Let’s Encrypt:
sudo yum install -y certbot python3-certbot-apache
Step 3: Obtain an SSL Certificate with Certbot
Run the following command to obtain a new SSL certificate and automatically configure Apache to use it:
sudo certbot --apache
Follow the prompts to enter your domain name(s), agree to the terms of service, and set up HTTP to HTTPS redirection.
Step 4: Verify the Installation
Once the process completes, open a web browser and navigate to https://yourdomain.com
to verify HTTPS is active.
Step 5: Set Up Automatic Renewal (Cron Job)
To ensure your certificate renews automatically, open the crontab editor:
sudo crontab -e
Add the following line to check for renewal twice daily:
30 2,14 * * * /usr/bin/certbot renew --quiet --renew-hook "systemctl reload httpd"
Step 6: Test the Renewal Process
Run a dry run of the renewal process to ensure it works:
sudo certbot renew --dry-run
If this completes without errors, Certbot is set up to renew the certificate automatically.