It’s a pain to add an SSL certificate to a web server. Fortunately, on the LAMP platform, you can make this IT task significantly easier with the help of Let’s Encrypt. Once this tool is installed, you can make short shrift of adding SSL certificates to your websites.

Let’s walk through the process of installing and using Let’s Encrypt. I’ll demonstrate the process on a Ubuntu Server 16.04 and assume you already have your LAMP server running and serving up websites.

SEE: Job description: Security Architect (Tech Pro Research)

How to install Let’s Encrypt

First, we must install Let’s Encrypt. Before we issue the installation command, let’s update apt with this command:

sudo apt-get update

After that completes, we’ll issue the following command to install Let’s Encrypt:

sudo apt-get install python-letsencrypt-apache

Depending upon your setup, you might see a number of dependencies to be installed; if you do, okay those installations and allow the process to complete. Once it’s finished, you’re ready to continue.

How to set up the SSL certificate

The next step is using letsencrypt to set up your certificate. Let’s use the domain for our demonstration. (Note: You must have a public-facing domain for this process, and the domain must be owned by you, have a DNS A record, and have a publicly routable IP address; otherwise, the process will fail.) In order to launch the interactive certificate setup, go back to your terminal window and issue the command (DOMAIN.COM is your actual domain):

sudo letsencrypt --apache -d DOMAIN.COM

The first window in the setup will ask for an email address (for notices and lost key recovery) (Figure A). Enter your email address and tab down to OK.

Figure A

The next window you must agree to is the EULA. That’s it–letsencrypt will do its thing and dump the original certificate files into /etc/letsencrypt/archive and create links to the most recent certificate files in /etc/letsencrypt/live (this is important after you’ve renewed your certificates…more on that in a bit). You can verify the status of the SSL certificate by pointing a browser to this link (DOMAIN.COM is your domain):

How to set up auto renewal of SSL certificates

By default, letsencrypt creates certificates that are valid for only 90 days; because of this, you need to set up a process that will auto renew those certificates. Since this is Linux, you can easily use cron for that job. To create a cronjob that will renew your certificates on the first day of every month at midnight, issue the command sudo crontab -e and then add the following:

0 0 1 * * /usr/bin/letsencrypt renew >> /var/log/letsencrypt-renew.log

Save and close that file. At this point, letsencrypt will automatically renew your certificate (by way of the letsencrypt-auto renew command) every month, so those certificates never expire.

Easy peasy

That’s it–you just created SSL certificates for your domain with the help of an incredibly easy to use tool. After using this method, you’ll never want to install a certificate in any other fashion.