Learn how to install an SSL certificate on Ubuntu for Apache web server.
With a secure certificate you will have your domain as https:// instead of just http:// .
You’ll use Let’s Encrypt to get the certificate for your Ubuntu server.
First update your Ubuntu server.
sudo apt update
Now install snapd
sudo apt install snapd
Remove certbot if you have it already installed
sudo apt-get remove certbot
Install the classic certbot version
sudo snap install --classic certbot
Now you can create your certificate for your domain, in the example I use mydomain.com but you should replace it by yours
sudo certbot --apache -d mydomain.com,www.mydomain.com
Try if the renewal process will work
--test renewal
sudo certbot renew --dry-run
Now check if you have a job to make automatic certificate renewals
-- to list all timers
sudo systemctl list-timers
References: