DEV Community

Samuel Oyetola
Samuel Oyetola

Posted on

How to Setup Let's Encrypt SSL with NGINX on Ubuntu 24.04 server

  • Install NGINX: If you haven't already installed NGINX on your Ubuntu 24.04 you can do so using the package manager

$sudo apt update
$sudo apt install nginx

  • Copy your default configuration file to your domain configuration file created (change myapp.com to your domain name)

$cp /etc/nginx/sites-available/default /etc/nginx/sites-available/myapp.com

  • Setup ssl for your domain by editing the domain configuration file, look for server_name _; and add your domain name in front of server_name _;

$nano /etc/nginx/sites-available/myapp.com
server_name myapp.com www.myapp.com; and save the configuration file

  • Unlink your default configuration file so that you can enable your domain configuration file

$unlink /etc/nginx/sites-enabled/default

  • Link your domain ( This automatically enable your domain configuration file)

$ln -s /etc/nginx/sites-available/myapp.com /etc/nginx/sites-enabled/myapp.com

After enable the domain you can then test

$nginx -t

Image description

$service nginx restart

  • Install Certbot for Let's encrypt SSL

$sudo apt-add-repository -r ppa:certbot/certbot (Press Enter)

Image description

$sudo apt install -y certbot python3-certbot-nginx

$certbot --nginx -d myapp.com -d myapp.com

Image description

Top comments (0)