Skip to content

Instantly share code, notes, and snippets.

@kevincharm
Last active January 22, 2020 19:40
Show Gist options
  • Save kevincharm/edf44072b39125769b85 to your computer and use it in GitHub Desktop.
Save kevincharm/edf44072b39125769b85 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