Skip to content

Instantly share code, notes, and snippets.

@alapini
Forked from kevincharm/letsencrypt-autogen.sh
Created June 29, 2017 08:13
Show Gist options
  • Save alapini/c00fe8628a295ddfdaf484f6bedcca92 to your computer and use it in GitHub Desktop.
Save alapini/c00fe8628a295ddfdaf484f6bedcca92 to your computer and use it in GitHub Desktop.
CentOS 7 Let's Encrypt SSL certs
#!/bin/bash
# Automates letsencrypt SSL cert generation/installation on CentOS 7 w/nginx
# MIT, use at your own risk blabla
EMAIL=foo@bar.com
DOMAIN_NAME=foo.bar.com
sudo su - root
cd ~
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
./letsencrypt-auto
systemctl stop nginx
./letsencrypt-auto certonly --standalone --email $EMAIL -d $DOMAIN_NAME --agree-tos --text
# This step is optional, specific to my setup. First pem file is ssl_certificate_key and second is ssl_certificate
ln -s /etc/letsencrypt/live/${DOMAIN_NAME}/privkey.pem /etc/ssl/${DOMAIN_NAME}.key
ln -s /etc/letsencrypt/live/${DOMAIN_NAME}/fullchain.pem /etc/ssl/${DOMAIN_NAME}.crt
systemctl start nginx
#!/bin/bash
# Renew certs
EMAIL=foo@bar.com
DOMAIN_NAME=foo.bar.com
cd ~
cd letsencrypt
systemctl stop nginx
./letsencrypt-auto certonly --standalone --email $EMAIL -d $DOMAIN_NAME --agree-tos --renew-by-default --text
systemctl start nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment