Allow both ports
$ sudo ufw allow 80
$ sudo ufw allow 443
Step 1 – Installing the "Let's Encrypt" package:
$ sudo apt install letsencrypt
Install timer for renewal:
$ sudo systemctl status certbot.timer
Step 2 – Standalone server for getting the "Let's Encrypt" SSL certificate:
$ sudo certbot certonly --standalone --agree-tos --preferred-challenges http -d domain-name.com
Step 3 – Automatic installation of the SSL certificate on nginx and Apache web servers:
$ apt install python3-certbot-apache
$ sudo certbot --apache --agree-tos --preferred-challenges http -d domain-name.com
or,
$ apt install python3-certbot-nginx
$ sudo certbot --nginx --agree-tos --preferred-challenges http -d domain-name.com
Step 4 – "Let's Encrypt" Wildcard SSL certificate
$ sudo certbot certonly --manual --agree-tos --preferred-challenges dns -d domain-name.com -d *.domain-name.com