AWS-How do I renew a Let’s Encrypt SSL certificate in a Bitnami stack hosted on a Lightsail instance

January 30, 2023 . 2 MIN READ

Renew existing certificate which is due to expire – AWS Lightsail

Lets encrypt SSL certificates are generally expired after 90 days of creation so need to be renewed regularly. If the expire date is near then you should renew manually first before adding an auto-renew cronjob (automate).

So here are the commands required to renew the current certificate in use, you should replace DOMAIN and EMAIL-ADDRESS with the relevant domain and email address of the previous certificate.

sudo /opt/bitnami/ctlscript.sh stop

Copy

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

Copy

sudo /opt/bitnami/ctlscript.sh start

Copy

Setup cron to automatically renew in future

You can also set it to autorenew using cronjob for that we need to create a script to run these command automatically by using following commands.

sudo mkdir -p /opt/bitnami/letsencrypt/scripts

Copy

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

Copy

After creating the script file we have to write the script inside the file. Following is the content of that script file.

#!/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

Copy

Now we need to make this script executable.

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

Copy

We have to make this file run by crontab so we need to edit crontab first.

sudo crontab -e

Copy

After opening crontab you have to add following content. This will make execute the script with this crontab.

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

 

#!/bin/bash

 

sudo /opt/bitnami/ctlscript.sh stop apache

sudo /opt/bitnami/letsencrypt/lego –tls –email=”john@grtidea.com” –domains=”godialogs.com” –path=”/opt/bitnami/letsencrypt” renew –days 90

sudo /opt/bitnami/ctlscript.sh start apache

Reference:

https://aws.amazon.com/premiumsupport/knowledge-center/lightsail-bitnami-renew-ssl-certificate/

https://s3bubble.com/setting-free-ssl-letsencrypt-certificate-lightsail-renewing/

https://www.seahorse-data.com/how-to-renew-the-lets-encrypt-certificate-on-bitnami-aws/

 

Leave a Reply

Your email address will not be published. Required fields are marked *