Skip to content

Instantly share code, notes, and snippets.

@EmadAdly
Last active October 10, 2022 08:13
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save EmadAdly/4bb320e37b4ec1e679e311593c9a081a to your computer and use it in GitHub Desktop.
Save EmadAdly/4bb320e37b4ec1e679e311593c9a081a to your computer and use it in GitHub Desktop.
Renew The Let’s Encrypt Certificate in bitnami

Renew The Let’s Encrypt Certificate

Let’s Encrypt certificates are only valid for 90 days. To renew the certificate before it expires, run the following commands from the server console as the bitnami user. Remember to replace the DOMAIN placeholder with your actual domain name, and the EMAIL-ADDRESS placeholder with your email address.

1- Login your server using SSH

ssh -i Key.pem bitnami@00.00.00.00

2- Stop Apache Server

sudo /opt/bitnami/ctlscript.sh stop

3- Renew Certificate

sudo /opt/bitnami/letsencrypt/lego --tls --email="EMAIL-ADDRESS" --domains="DOMAIN" --path="/opt/bitnami/letsencrypt" renew --days 90

4- Start Apache Server

sudo /opt/bitnami/ctlscript.sh start


Automatically renew

To automatically renew your certificates before they expire, write a script to perform the above tasks and schedule a cron job to run the script periodically. To do this:

  • Create a script at /opt/bitnami/letsencrypt/scripts/renew-certificate.sh

sudo nano /opt/bitnami/letsencrypt/scripts/renew-certificate.sh

Enter the following content into the script and save it. Remember to replace the DOMAIN placeholder with your actual domain name, and the EMAIL-ADDRESS placeholder with your email address.

#!/bin/bash

sudo /opt/bitnami/ctlscript.sh stop apache
sudo /opt/bitnami/letsencrypt/lego --tls --email="EMAIL-ADDRESS" --domains="DOMAIN" --path="/opt/bitnami/letsencrypt" renew --days 90
sudo /opt/bitnami/ctlscript.sh start apache
  • Make the script executable:

chmod +x /opt/bitnami/letsencrypt/scripts/renew-certificate.sh

  • Execute the following command to open the crontab editor:

sudo crontab -e

  • Add the following lines to the crontab file and save it:

0 0 1 * * /opt/bitnami/letsencrypt/scripts/renew-certificate.sh 2> /dev/null

NOTE: If renewing multiple domains, remember to update the /opt/bitnami/letsencrypt/renew-certificate.sh script to include the additional domain name(s) in the lego command.

@mtbluedog
Copy link

Needs to be renew --days=90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment