VOOZH about

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

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


How To Secure Apache with Let's Encrypt on Ubuntu 18.04

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

Introduction

Let’s Encrypt is a Certificate Authority (CA) that provides a way to obtain and install free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. It streamlines the process by providing a software client, Certbot, that attempts to automate most (if not all) of the required steps. Currently, the entire process of obtaining and installing a certificate is fully automated on both Apache and Nginx.

In this tutorial, you will use Certbot to obtain a free SSL certificate for Apache on Ubuntu 18.04 and verify that your certificate is set up to renew automatically.

This tutorial uses a separate Apache virtual host file instead of the 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 in a server, because it helps to avoid common mistakes and maintains the default files as a fallback setup.

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)

Former Developer at DigitalOcean community. Expertise in areas including Ubuntu, Docker, Ruby on Rails, Debian, and more.

👁 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.

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!

certbot is now in standard ubuntu repository. No need to add ppa repository. Use python3-certbot-apache plugin from standard reepository.

Hi,

I have got two sites running on VirtualHosts. (/var/www/site1 and /var/www/site2) I want to get a SSL for them. When I try to sudo apache2ctl configtest I get this warning:

AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 192.168.2.8. Set the ‘ServerName’ directive globally to suppress this message Syntax OK

What can I do to fix this?

Greetings.

How would I add wildcard dns?

I followed your procedure and it worked like a charm except … I have a WebSocket app behind my Nginx reverse proxy server. My app runs flawlessly in Chrome but Firefox won’t even load it. The issue revolves around communicating with ws over https. Firefox ran the app flawlessly prior to my encrypting my Nginx reverse proxy server. How do you suggest I proceed? Encrypting my Haskell server and Cycle.js front end would be difficult - for me anyway.

Hi There,

Thanks the tutorial. However, I tried installing certbot with the instructions given but it kept showing error messages:

root@solpro:~# sudo add-apt -repository ppa:cerbot/certbot
sudo: add-apt: command not found
root@solpro:~# -repository ppa:cerbot/certbot
-repository: command not found
root@solpro:~# ppa:cerbot/certbot
-bash: ppa:cerbot/certbot: No such file or directory
root@solpro:~# cerbot/certbot
-bash: cerbot/certbot: No such file or directory
root@solpro:~# sudo apt install python-certbot-apache
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-certbot-apache
root@solpro:~# sudo add-apt-repository ppa:cerbot/certbot
Cannot add PPA: 'ppa:~cerbot/ubuntu/certbot'.
ERROR: '~cerbot' user or team does not exist.

What am I doing wrong?

Yes the part to install certbot does not work. So when I run this: sudo add-apt-repository ppa:certbot/certbot

I get this: Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Hit:2 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease Get:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB] Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Fetched 172 kB in 5s (31.4 kB/s) Reading package lists… Done

everything sees to be ok so far … however when I run this: sudo apt install python-certbot-apache

I get this: The following packages have unmet dependencies: python-certbot-apache : Depends: python3-certbot-apache but it is not going to be installed E: Unable to correct problems, you have held broken packages.

I have done everything prior to this on the main How to setup Owncloud on Ubuntu 18.04 …which by the way is very time consuming just to be stuck at a dead end now. I am using Ubuntu 18.04 server.

any help with this would be great thanks!

For anyone getting the following error on the installation of the Certbot’s Apache packages in Ubuntu 18.04

The following packages have unmet dependencies:
python-certbot-apache : Depends: python3-certbot-apache but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

You will have to add the “Universe” repository using the following command:

sudo add-apt-repository universe

Also, make sure your system is up to date (sudo apt update + sudo apt upgrade).

You are missing before step one a very important step:

sudo apt-get install -y software-properties-common

GLHF

You say as a prerequisite; “A fully registered domain name. This tutorial will use example.com throughout. You can purchase a domain name on Namecheap, get one for free on Freenom, or use the domain registrar of your choice.”

But although I have a web application and a domain name, because it is in an hosting server, I cannot intervene the configurations of server. Just testing purpose, how can I simulate and experience this process in my “local” system? Is there any way?

I think I followed the tutorial carefully and didn’t notice the error messages that the other users experienced, but I just get ‘Unable to connect’ messages. Can you point out where I might have gone wrong.

👁 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.