Skip to content


Installing Letsencrypt

Letsencrypt provides the certbot library to manage its SSL certficates

Package Manager

Letsencrypt might be available in your server's package manager. If so this is the easiest means of installing it

Download the binary

chmod a+x certbot-auto

Git clone

git clone
cd letsencrypt

Installing an SSL Certificate

certbot-auto certonly --standalone -d -d

Certbot will try to temprarily set up a web server to authenticate itself. If this isn't possible because the port is in use, you can use an existing web root:

certbot-auto certonly --webroot --webroot-path=/path/to/web/root/

The certificates are installed in /etc/letsencrypt/ thusly:

root@localhost tree /etc/letsencrypt/live/
├── cert.pem -> ../../archive/
├── chain.pem -> ../../archive/
├── fullchain.pem -> ../../archive/
└── privkey.pem -> ../../archive/

You can then use these in your web server config:

    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;

Auto Renewal

Create a letsencrypt-renew.bash file:

#!/usr/bin/env bash
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
cd $DIR;
set -e
set -u
set -o pipefail
echo "
$(hostname) $0 $@
/root/letsencrypt/certbot-auto renew && systemctl reload nginx

And run it from cron:

0 0 1 * * /var/www/vhosts/ > /tmp/renew.log

Using Certbot

Auto renewing on Centos

To auto renew we should use the the systemd timer.

To start and enable the timer systemctl start certbot-renew.timer and systemctl enable certbot-renew.timer.

To list all the timers use systemctl list-timers, you should see certbot-renew.timer in the list.