Skip to content

How to Secure Apache With Let’s Encrypt on Ubuntu 18.04 & 16.04

How To Configure Apache with Let's Encrypt SSL on Ubuntu 18.04, 16.04 & 14.04. How To Configure Let's Encrypt SSL with Apache on Ubuntu 18.04 & 16.04

Steps
4
Category
Security
Covers
Apache, Let's Encrypt, SSL/TLS
On this page 4 steps

Let’s Encrypt is a certificate authority (CA) providing free SSL/TLS certificates for enhanced security freely. You can generate CA-singed SSL certificate for any domain, subdomain without any cost and use on your server. It also provides an option to auto-renew SSL certificates for long time use.

This tutorial will help you to install Let’s encrypt client on Ubuntu system. Also issue a free ssl certificate and configure with Apache server.

Step 1 of 4Prerequisites

Before starting work on this task, I assume you already have:

  • Running Ubuntu system with sudo privileges shell access.
  • A domain name registered and pointed to your server’s public IP address. For this tutorial, we use example.com and www.example.com, which is pointed to our server.
  • Running Apache2 server with VirtualHost configured for example.com and www.example.com for Port 80.

Step 2 of 4Install Let’s Encrypt Client

You can download the certbot-auto Let’s Encrypt client and save it in /usr/sbin directory. Use the following command to do it.

sudo wget https://dl.eff.org/certbot-auto -O /usr/sbin/certbot-auto
sudo chmod a+x /usr/sbin/certbot-auto

Step 3 of 4Issue SSL from Let’s Encrypt

Let’s Encrypt performs Domain Validation (DV) automatically with multiple challenges. Once the Certificate Authority (CA) verified the authenticity of your domain, SSL certificate will be issued.

You don’t need to create VirtualHost for SSL/HTTPS, Let’s encrypt will create it. You only need to create VirtualHost for port 80 only.

sudo certbot-auto --apache -d example.com  -d www.example.com

Above command will prompt for an email address, which is used for sending email alerts related to SSL renewal and expiration. Also, asks a few more questions. After completion, it will issue an SSL certificate and will also create a new VirtualHost configuration file on your system.

Step 4 of 4Configure SSL Auto Renew

At the end, configure the following job on your server crontab to auto-renew SSL certificate if required.

0 2 * * * sudo certbot-auto -q renew

You may like:

Conclusion

In this tutorial, you have learned to configure free ssl certificate using let’s encrypt on Apache server.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

3 Comments

  1. while installing let’s encrypt got this error “Cannot find a cert or key directive in /files/etc/httpd/conf/httpd-le-ssl.conf/IfModule/VirtualHost. VirtualHost was not modified”

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top