How to Install Let’s Encrypt with NginX on Ubuntu 16.04 and Ubuntu 18.04

Blog post banner with Let's Encrypt, Nginx and Ubuntu logosThis is a step-by-step instruction of how to install Let’s Encrypt SSL with NginX on your Ubuntu 16.04 or Ubuntu 18.04 (both are popular LTS releases). I will try to describe several useful settings that will make configuration easy and smart. I will use different commands that will be executed due to the Ubuntu version differences. Those blocks will be highlighted so pay attention to that, but almost everything should be the same.


You need Ubuntu 16.04 or Ubuntu 18.04 server with SSH access, registered domain name pointed to your server’s IP and small portion of knowledge of how to use Linux console and execute commands on the Ubuntu server. The whole installation will take around 30 minutes.

Step 1 – Install LetsEncrypt

Before installing new soft you should always consider to update the package list in order to have your software up to date.

sudo apt-get update

Add software repository Ubuntu 16.04

Add software repository Ubuntu 18.04


For now, everything is ready to install LetsEncrypt on your server:

sudo apt-get install letsencrypt

This command will install letsencrypt dummy package that includes certbot and other utilities for SSL installation.

Step 2 – Configure NginX for Let’s Encrypt SSL

In my configuration examples I will use the following domain name ‘‘. Do not forget to change it for your needs when you do a copy-paste. Now it’s time for a small life-hack that will show you how to optimize the process of adding new certificates to your server. We will use NginX default config to catch all requests with non-secure connection that are going to our server aka non-ssl which will target 80 port.

As you can see we are using   /\.well-known/acme-challenge/ directory to catch all requests for location and /var/www/letsencrypt  directory to host acme-challenges. So let’s create directory after you edited the default NginX vhost config:

Before applying changes to your NginX settings always check configuration file:

sudo nginx -t

You should get a notification that syntax is ok:

To apply changes to our new NginX vhost configuration that is designed to catch all of your Let’s Encrypt certificates challenges do the following:

sudo service nginx reload

Step 3 – Request new Let’s Encrypt SSL

Now it is time to request our first Let’s Encrypt SSL certificate for our domain:

Let me describe some important options in our command:

--webroot-path=/var/www/letsencrypt – here we configure a directory where all requests will be stored. We configured NginX to serve this directory.

-m – with this option you are setting up your e-mail address

--agree-tos – this option is needed not to prepare TOS and to accept them. This is some kind of fully automated way to install Let’s Encrypt SSL

-d – this option is used to issue SSL for the desired domain

After command execution you should see Congratulations message:

Step 4 – Configure NginX vhost

Now we have new SSL installed to ‘/etc/letsencrypt/live/‘. It’s time to configure our NginX vhost to serve https requests for the desired domain. Here is my example:

Let’s test and reload our new NginX configuration:

sudo nginx -t

sudo service nginx reload

Step 5 – Configure Let’s Encrypt SSL auto renewal

Let’s Encrypt issues certificates for 90 days. You have an opportunity to reinstall it manually when you got the email that your SSL expires soon, but I think there is a smart way to automate that. We will use daily cron on our Ubuntu server to renew our SSL certificate. Due to the different version of the letsencrypt package in Ubuntu 16.04 and Ubuntu 18.04, I will use different renewal commands.

Ubuntu 16.04 Let’s Encrypt renewal

I use ‘/etc/cron.daily/letsencrypt‘ file to setup cron with the following content:

Ubuntu 18.04 Let’s Encrypt renewal

I use the same file ‘/etc/cron.daily/letsencrypt‘ but with another content:

Step 6 – Test SSL configuration

When we are done with configuration it’s time to take a cup of coffee and relax test our configuration. There are dozens of options to test SSL, but I will use two, the first one is curl:

The second option is to open your site in Google Chrome and check SSL certificate in dev tool under security tab:

Check Letsencrypt SSL in chrome







Now you know how to install Let’s Encrypt SSL on Ubuntu 16.04 or Ubuntu 18.04 to secure your site. It is very simple, useful and cheap solution to protect your site and improve a bit your SEO rankings. If you have issues with installation or you want to save your time – ask our technicians to maintain your server for you. Comments, improvements and critics are always welcome!

ITsyndicate contact form

Contact us if you have any questions!