Install certbot and get a SSL certificate on Rocky Linux 9

In this article we will install certbot and get a SSL certificate on Rocky Linux 9 from Let’s encrypt including how to renew and delete them when needed.

Installation and getting certificate

Install certbot through dnf package manager.

dnf install certbot

To get only a certificate without web root.

certbot certonly -d DOAMIN.COM 

To get a certificate with web root.

certbot certonly --webroot -w /var/www/html -d DOAMIN.COM

If you are testing a website you can get a staging certificate which you can upgrade by running the above command later.

certbot certonly --test-cert --webroot -w /var/www/html -d DOAMIN.COM

Renew

You can use cronjob to renew the certificates.

Cron job commands are, to list crontab -l, to edit crontab -e

30 04 * * * certbot renew

This will run at 4.30AM.

Delete

To delete a certificate you don’t need to remove directories like live/archive/renew etc anymore manually, just run the following command and you are good to go.

certbot delete --cert-name DOMAIN.COM