Ubuntu 20.04 & 22.04

Install Certbot package. Available standard repository.

$ sudo apt install certbot python3-certbot-apache

Before execution ‘certbot’, rewrite apache module must be available.

$ sudo -i
# a2enmod rewrite

1st time recommended command is

# certbot --apache

This command is able to find non ssl web setting and auto update certificate and chain by reading /etc/apache2/sites-available directory. And also is fixes virtual host configuration files. And then restarting apache.

# systemctl restart apache2.service
Renewal certification file, certbot-auto command.
# certbot renew --post-hook "systemctl restart apache2.service"

also available cron daemon setting.

example file, letsencrypt  can be put on /etc/cron.monthly/ ,

#!/bin/sh

# update (renew) cert.
/usr/bin/certbot renew --post-hook "systemctl restart apache2.service"

Japanese “Let’s Encrypt” site is https://letsencrypt.jp/.