VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04?comment=92964

⇱ How To Secure Apache with Let's Encrypt on Ubuntu | DigitalOcean


How To Secure Apache with Let's Encrypt on Ubuntu

Updated on December 18, 2025
Not using Ubuntu 20.04?
Choose a different version or distribution.
Ubuntu 20.04
👁 How To Secure Apache with Let's Encrypt on Ubuntu

Introduction

Serving your Apache site over HTTPS encrypts traffic between clients and your server, preventing passive interception and tampering. Let’s Encrypt is a Certificate Authority (CA) that provides free TLS/SSL certificates, enabling encrypted HTTPS on web servers without the cost and complexity of traditional certificate authorities.

Certbot, the official Let’s Encrypt client, automates the entire process of obtaining, installing, and renewing SSL certificates for Apache on Ubuntu 20.04. With a single command, you can configure your web server to serve encrypted traffic and automatically renew certificates before they expire.

This tutorial uses a separate virtual host file instead of Apache’s default configuration file for setting up the website that will be secured by Let’s Encrypt. We recommend creating new Apache virtual host files for each domain hosted on a server, as this helps to avoid common mistakes and maintains the default configuration files as a fallback setup.

Deploy your frontend applications from GitHub using DigitalOcean App Platform. Let DigitalOcean focus on scaling your app.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

👁 Erika Heidi
Erika Heidi
Author
Developer Advocate
See author profile

Dev/Ops passionate about open source, PHP, and Linux. Former Senior Technical Writer at DigitalOcean. Areas of expertise include LAMP Stack, Ubuntu, Debian 11, Linux, Ansible, and more.

👁 Vinayak Baranwal
Vinayak Baranwal
Editor
Technical Writer II
See author profile

Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator. Technical Writer @ DigitalOcean | GitHub Contributor | Passionate about Docker, PostgreSQL, and Open Source | Exploring NLP & AI-TensorFlow | Nailed over 50+ deployments across production environments.

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

can you make it for ngnix? getting code An unexpected error occurred: AttributeError: module ‘acme.challenges’ has no attribute ‘TLSSNI01’

The original Ubuntu 20.04 package have this bugs it did not install the right python3-certbot-nginx

So the only solution for ubuntu (AMD64) are via snap

  1. sudo snap install certbot --beta --classic

or

sudo add-apt-repository ppa:ahasenack/certbot-tlssni01-1875471
sudo apt-get update

Thanks to Andreas for making his PPA available temporarily to fixed the problem

I hope this will help people who want to upgrade to 20.04

You can re-run “certbot --apache” so that the script can automatically redirect http to https. In case you originally chose to not auto-configure this.

I can confirm that this works like a charm on Ubuntu 20.04. Simple! Thanks.

Step 3 /etc/apache2/sites-available/your_domain.conf

… ServerName your_domain ServerAlias www.your_domain …

do I need to change the name like this if my domain name is examplesite

/etc/apache2/sites-available/examplesite.conf

… ServerName examplesite ServerAlias www.examplesite …

Thanks a lot, everything works fine. All I had to do was enter sudo a2dissite default-ssl.conf

Fantastic tutorial! Thank you 🤩

Hi, thanks for your guide.

One question, can I follow this guide with a subdomain? So that I don’t have to purchase and maintain another domain name?

Im trying to increase the security of the access of phpmyadmin of my server.

Thanks.

Just do it step by step. Thank you very much!

E: Package ‘python-virtualenv’ has no installation candidate when I execute sudo certbot --apache Anyone else facing this?

:~# sudo certbot --apache
Bootstrapping dependencies for Debian-based OSes... (you can skip this with --no-bootstrap)
Ign:1 http://ppa.launchpad.net/certbot/certbot/ubuntu focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Err:3 http://ppa.launchpad.net/certbot/certbot/ubuntu focal Release
 404 Not Found [IP: 2001:67c:1560:8008::15 80]
Hit:4 https://repos.insights.digitalocean.com/apt/do-agent main InRelease
Get:5 http://mirrors.digitalocean.com/ubuntu focal InRelease [265 kB]
Hit:6 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease
Hit:7 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease
Hit:8 http://security.ubuntu.com/ubuntu focal-security InRelease
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/certbot/certbot/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
apt-get update hit problems but continuing anyway...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'python-is-python2' instead of 'python'
Note, selecting 'python-dev-is-python2' instead of 'python-dev'
Package python-virtualenv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-virtualenv' has no installation candidate
👁 Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.