Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save globian/65e1345ebdcceed6dbecd127a6efcc8c to your computer and use it in GitHub Desktop.
Save globian/65e1345ebdcceed6dbecd127a6efcc8c to your computer and use it in GitHub Desktop.
Install and configure LetsEncrypt on Ubuntu Server 14.04 & 16.04 (Apache)
#!/bin/bash
# https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-14-04
# Download the Let’s Encrypt Client
cd /usr/local/sbin
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x /usr/local/sbin/certbot-auto
# Set Up the SSL Certificate
certbot-auto --apache -d example.com
# Remove above and uncomment below if you want to include sub domains
#certbot-auto --apache -d example.com -d www.example.com
# Creating a new Cronjob when no Cron jobs exist while running crontab -e as root?
echo "30 2 * * 1 /usr/local/sbin/certbot-auto renew > /var/log/le-renew.log" >> /var/spool/cron/crontabs/root
chown root:root /var/spool/cron/crontabs/root
chmod 600 /var/spool/cron/crontabs/root
# Remove above and uncomment below if you want to append to an existing list of Cron jobs, i.e. Cron jobs exist when running crontab -e?
#echo "30 2 * * 1 /usr/local/sbin/certbot-auto renew >> /var/log/le-renew.log" >> /var/spool/cron/crontabs/root
-- EDIT -- 3 Sept 2021
Since April of 2019, there are no longer updates for Ubuntu 14.04 which seems to have broken the installation steps that are outlined above.
Further to this, it seems that certbot-auto is no longer supported.
I have not tested any solution as no longer make use of 14.04.
This said, in 14.04 you could perhaps try to install snapd:
sudo apt update
sudo apt install snapd
Remove the existing certbot-auto install:
sudo rm -rf /usr/local/sbin/certbot-auto
Then try to use snap to install certbot:
sudo snap install --classic certbot
The steps for 16.04 would perhaps be the same with the only exception being, snap is already installed in 16.04 so you would simply need to update it:
sudo snap install core; sudo snap refresh core
When I had created this gist, the instructions on how to make use of Lets Encrypt were not very clear.
since then things have changed a lot and there is great documentation available for you to make use of:
https://certbot.eff.org/instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment