Install Certificate with lets Encrypt on Ubuntu 24

Create a dns record on your domain (Hosting)

Open firewall ports 80 and 443 to your server

If you use a firewall on Ubuntu

sudo ufw allow 80
sudo ufw allow 443

sudo apt install apache2 -y

sudo apt install letsencrypt -y

sudo systemctl status certbot.timer -y

Standalone server for getting the "Let's Encrypt" SSL certificate

sudo certbot certonly --standalone --agree-tos --preferred-challenges http -d domain-name.com

The certonly option means that the certificate will only be obtained without installation on any web server, standalone allows you to start your own web server for authentication, agree-tos means acceptance of the ACME server subscription agreement, which is a prerequisite, and preferred-challenges http means performing authorization using HTTP

Automatic installation of the SSL certificate on nginx and Apache web servers

apt install python3-certbot-nginx

apt install python3-certbot-apache

Run this command for nginx:

sudo certbot --nginx --agree-tos --preferred-challenges http -d domain-name.com

Or this for Apache:
sudo certbot --apache --agree-tos --preferred-challenges http -d domain-name.com