Lets Encrypt is a great certificate generator for servers requiring HTTPS support (and let’s face it, it should be 100% of websites by now). Instructions on how to set up Let’s Encrypt are easy enough to follow, but renewing certificates when the time comes can be tedious.
I don’t currently auto-renew my certificates, but I do certify a bunch of domains on my server. I use a simple bash script to shut down my nginx server, renew each certificate, and then restart the web server after everything is ready. Check it out:
#!/bin/bash
domains=("mysite.com" "anothersize.com" "final.org")
echo "Stopping Nginx..."
sudo service nginx stop
for domain in "${domains[@]}"
do
:
echo "-> Renewing domain $domain"
sudo letsencrypt -d $domain certonly
echo
done
echo "Starting Nginx..."
sudo service nginx start
Simply write this to a file, and then set the file as executable: chmod +x myscript.sh
. Make sure to place your domains in the domains
array.