Renew Let's Encrypt Certificate

Renew Let's Encrypt Certificate

 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.

sudo /opt/bitnami/ctlscript.sh stop
sudo /opt/bitnami/letsencrypt/lego --tls --email="EMAIL-ADDRESS" --domains="DOMAIN" --path="/opt/bitnami/letsencrypt" renew --days 90
sudo /opt/bitnami/ctlscript.sh start

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.

    For Apache:

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

    For NGINX:

    #!/bin/bash
    
    sudo /opt/bitnami/ctlscript.sh stop nginx
    sudo /opt/bitnami/letsencrypt/lego --tls --email="EMAIL-ADDRESS" --domains="DOMAIN" --path="/opt/bitnami/letsencrypt" renew --days 90
    sudo /opt/bitnami/ctlscript.sh start nginx
    
  • 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.

To learn more about the topics discussed in this guide, consider visiting the following links:


    • Related Articles

    • Generate and Install a Let's Encrypt SSL Certificate for a Bitnami Application

      Assumptions and prerequisites This guide assumes that: You have deployed a Bitnami application and the application is available at a public IP address so that the Let’s Encrypt process can verify your domain. You have the necessary credentials to log ...
    • Creating Quizzes and Uploading to the Moodle LMS Interface

      Depending on the situation, it may be easier to insert new quiz questions into Moodle by creating them one by one. However, if a publisher has provided a list of questions in Word format, it is possible to import them into Moodle automatically. ...
    • CONTRA COSTA COUNTY DIVORCE ROADMAP

      https://www.cc-courts.org/family/divorce-roadmap.aspx CONTRA COSTA COUNTY DIVORCE ROADMAP https://www.cc-courts.org/family/divorce-roadmap.aspx#contested Información en Español Locations FAQ Contact Home Online Services Info Centers Departments ...