How to Install Let’s Encrypt SSL Certificate on CentOS 7

Install Let’s Encrypt SSL

Prerequisites:

  1. CentOS 7 server set up with a non-root user who has sudo privileges.
  2. Apache installed on the CentOS 7 server with a virtual host configured for your domain.
  3. Registered domain name that you wish to use the certificate with.
  4. DNS A Record pointing your domain to the public IP address of your server.

Step 1: Installing the Certbot Let’s Encrypt Client

First, enable the EPEL repository and install the required packages:

sudo yum install epel-release
sudo yum install certbot python-certbot-apache mod_ssl

Step 2: Configure Apache

Ensure that Apache is properly configured with your virtual host file for your domain (e.g., /etc/httpd/sites-available/example.com.conf).

Step 3: Obtain and Install SSL for Your Domain

Run the following command to obtain and install the SSL certificate:

sudo certbot --apache

Certbot will guide you through the process, prompting you to select the domain and configure HTTPS settings.

Step 4: Check Your SSL Certificate

Visit your website using https://yourdomain.com to verify that the SSL certificate is working correctly.

Step 5: Set up Automatic Renewal

Let’s Encrypt certificates expire after 90 days. To automate renewal, create a cron job:

sudo crontab -e

Add the following line to run the renewal process every week:

0 0 * * 0 /usr/bin/certbot renew

That’s it! You now have a secure Let’s Encrypt SSL certificate installed on your CentOS 7 VPS. Remember to keep your server and certificates up to date.