How To Install Apache with Let’s Encrypt SSL on Ubuntu 20.04 LTS

Install Apache with Let’s Encrypt SSL on Ubuntu 20.04

In this tutorial, we will show you how to install Apache with Let’s Encrypt SSL on Ubuntu 20.04 LTS. For those of you who didn’t know, Let’s Encrypt is a certificate authority that provides free SSL certificates for websites. All SSL certificates provided by Let’s Encrypt can be used for production/commercial purposes without any costs or fees. This guide will tell you about installing the Apache web server, installing the Certbot, generating an SSL certificate with Certbot, and creating additional SSL configuration to get the A+ from the SSL test SSL Labs.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Apache with free SSL on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.


  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Apache with Let’s Encrypt SSL on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Installing Apache on Ubuntu 20.04.

By default, Apache is available on Ubuntu 20.04 base repository. Now we install the Apache webserver on the Ubuntu system by running the following command below:

sudo apt install apache2 apache2-utils

Before starting the configurations, make sure that Apache services are running on your system. Run the following command to check the apache services status:

sudo systemctl status apache2
sudo systemctl start apache2
sudo systemctl enable apache2

Step 3. Configure Firewall.

Allow access to port 80 on the firewall by running the below-given command:

sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable

Step 4. Configure the Apache Virtual Host.

First, create a root directory to hold your website’s files:

sudo mkdir -p /var/www/html/

Then, change the ownership and group of the directory:

sudo chown -R www-data:www-data /var/www/html/

Let’s create an Apache virtual host to serve the HTTP version of your website:

sudo nano /etc/apache2/sites-available/

Add the following line:

<VirtualHost *:80>

   DocumentRoot /var/www/html/

   ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
   CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

   <Directory /var/www/html/>
      Options FollowSymlinks
      AllowOverride All
      Require all granted


Save and close, then restart the Apache webserver so that the changes take place:

sudo a2ensite
sudo a2enmod ssl rewrite
sudo systemctl restart apache2

Step 5. Secure Apache with Let’s Encrypt SSL Free Certificate.

Before installing Certbot, we enable the universe repository to your system:

sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update

Next, install Certbot for Apache on your Ubuntu system:

sudo apt install certbot python3-certbot-apache

Finally, use the Certbot command to create a Let’s Encrypt certificate and configure Apache to use the certificate:

sudo certbot --apache


Congratulations! You have successfully enabled and

You should test your configuration at:

- Congratulations! Your certificate and chain have been saved at:
Your key file has been saved at:
Your cert will expire on 2021-10-05. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt:
Donating to EFF:

Step 5. Auto-Renewal Certbot SSL.

Let’s Encrypt certificates have a validity of 90 days, and you have to ensure they are renewed on time. The renewal process is now automated and thanks to the systemd service provided by the Certbot client. To test that this renewal process is working correctly, you can run:

sudo certbot renew --dry-run


Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for and

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded: 
  /etc/letsencrypt/live/ (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Step 7. Test SSL.

You can now go to and run an SSL test on your domain:

Install Nginx with Let’s Encrypt SSL on Ubuntu 20.04

Congratulations! You have successfully installed Apache with a free SSL certificate. Thanks for using this tutorial for installing the Apache webserver Let’s Encrypt SSL on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Apache website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button