Skip to Content

How to install free SSL with Let’s Encrypt?

You can automatically enable HTTPS on your website with EFF’s Certbot, deploying Let’s Encrypt certificates

 

1. Install snapd

    Installing snap on Red Hat Enterprise Linux (RHEL) / Centos

     Adding EPEL Repo RHEL

      The EPEL repository can be added to a RHEL 8 system with the following command:

       The EPEL repository can be added to a RHEL 7 system with the following command:

$ sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 

    Adding the optional and extras repositories is also recommended:

$ sudo subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms"

$ sudo yum update

 

 Adding EPEL to CentOS

    The EPEL repository can be added to a CentOS 8   system with the following command:

$ sudo dnf install epel-release

$ sudo dnf upgrade

    The EPEL repository can be added to a CentOS 7 system with the following command:

$ sudo yum install epel-release

  Installing snapd

$ sudo yum install snapd

 

  Installing snap on Debian Apache on CentOS/RHEL 7

    On Debian 10 (Buster) and Debian 9 (Stretch), snap can be installed directly from the command line:

$ sudo apt update

$ sudo apt install snapd 

  Installing snap on Ubuntu

     If you’re running Ubuntu 16.04 LTS (Xenial Xerus) or later, you don’t need to do anything. Snap is already installed and ready to go.

 

2. Ensure that your version of snapd is up to date

     Execute the following instructions on the command line on the machine to ensure that you have the latest version of snapd.

sudo snap install core; sudo snap refresh core

 

3. Remove certbot-auto and any Certbot OS packages 

       If you have any Certbot packages installed using an OS package manager like apt, dnf, or yum, you should remove them before installing the Certbot snap to ensure that when you run the command certbot the snap is used rather than the installation from your OS package manager. The exact command to do this depends on your OS, but common examples are sudo apt-get remove certbot, sudo dnf remove certbot, or sudo yum remove certbot.

 

4. Install Certbot

    Run this command on the command line on the machine to install Certbot.

sudo snap install --classic certbot

 

 5. Execute the following instruction on the command line on the machine to ensure that the certbot command can be run.

sudo ln -s /snap/bin/certbot /usr/bin/certbot

 

 6. Run this command to get a certificate and have Certbot edit your Apache configuration automatically to serve it, turning on HTTPS access in a single step.

Make sure to add virtualhost configuration  for the domain

sudo certbot --apache

   

 7.  Test automatic renewal

       The Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration. You can test automatic renewal for your certificates by running this command:

 

sudo certbot renew --dry-run 

 

The command to renew certbot is installed in one of the following locations :

/etc/crontab/

/etc/cron.*/*

systemctl list-timers

 
More detailed information  can be found in  Certbot documentation