Skip to content

Instantly share code, notes, and snippets.

@brunston
Created February 13, 2017 22:09
Show Gist options
  • Save brunston/3c5b032f7a4c4882955f1c8985ca7fb1 to your computer and use it in GitHub Desktop.
Save brunston/3c5b032f7a4c4882955f1c8985ca7fb1 to your computer and use it in GitHub Desktop.
Let's Encrypt with LAMP

Using Let's Encrypt with a LAMP stack (Apache Web Server)

Quick intro: Let's Encrypt is a relatively new certificate authority which issues SSL certificates using an automated system that issues challenges to the specified server to ensure that the server controls the domain which is attempting the automated certification process. The certificates last only 90 days but can be renewed indefinitely.

Update and install the Let's Encrypt client

On Ubuntu 16.04:

sudo apt-get update
sudo apt-get install letsencrypt python-letsencrypt-apache

As long as virtualhosts are correctly configured on the Apache webserver, the following command is all that's necessary to automatically receive an SSL certificate from Let's Encrypt.

sudo letsencrypt --apache -d <DOMAIN HERE>

Automate the renewal process

sudo letsencrypt renew renews all the domains on the server secured with Let's Encrypt as long as there are less than 30 days remaining until the certificate expires. We can automate the renewal process via cron.

Editing crontab:

sudo crontab -e

Once in the editor, we can write a script that runs at 6:00am every Monday morning and pipes the output to a log file. Append the following to the end of crontab

# 0 minutes, 6 hours, ..., every monday
0 6 * * 1 /usr/bin/letsencrypt renew >> /var/log/ssl-renewal.log

This concludes the setup for Let's Encrypt SSL on a LAMP stack on Ubuntu 16.04.

This walkthrough is a simplified version of what is available from DigitalOcean docs here: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment