Complete Step by Step Guide for Installing Apache with Free SSL enabled on Ubuntu/Linux – 2019


The goal of this article is to go through all the steps necessary to install and configure Apache on Linux, including Free SSL certificate so you have a working SSL protected website by the end. We will use our as our example domain for this article.


  • Installing Apache
  • Configure DigitalOcean DNS
  • Install Let’s Encrypt Free SSL/TLS Certificate
  • Replace Default Apache Website


Installing Apache

Simple step by step instructions on how to install Apache on Linux:

Step 1

Run update command to update package repositories and get latest package information.

sudo apt-get update -y

Note: -y flag means to assume yes and silently install, without asking you questions in most cases.

Step 2
Install Apache Client:
sudo apt-get install -y apache2

Step 3
If you have active Firewall adjust it and enable Apache Server:

sudo ufw allow 'Apache Full'

You can verify the change by running this command:

sudo ufw status

You should see an output like this after running command:

Step 4

Change default virtual host file 000-default.conf located in /etc/apache2/sites-enabled/ with this:

Configure DigitalOcean DNS

Step by Step instructions on configuring DNS for your domain and www subdomain.

Step 1

On your DigitalOcean page navigate to ManageNetworking:

Step 2

Enter domain name (in our example and click Add Domain:

Step 3

After this you should see that this zones are already created.

If not, create them and other necessary zones. We will also create two A zones for domain and www subdomain.

Step 4

Verify DNS Updates have been saved properly. See an Example image below:

Install Let’s Encrypt Free SSL/TLS Certificate

Step By Step instructions on how to get and apply Free SSL/TLS Certificate for both your domain and www subdomain.

Step 1

Certbot currently requires Python 2.7 or 3.4+ running on a UNIX-like operating system. In order to install Python 3.6 run this command:

sudo apt-get install -y python3.6

Step 2

On Ubuntu systems, the Certbot team maintains a PPA. You can add it to your list of repositories and install Certbot by running the following commands.

sudo apt-get update -y

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

sudo add-apt-repository -y universe

sudo add-apt-repository -y ppa:certbot/certbot

sudo apt-get update -y

sudo apt-get install -y certbot python-certbot-apache

Step 3

Get certificate:

sudo certbot --apache

Note: you will be asked to enter some information like email address, domains (,, etc. For a single line non-interactive command you can use this:

certbot run -n -a webroot -i apache -w /var/www/html -d -d --agree-tos --email

Step 4

The Certbot packages on your system come with a cron job that will renew your certificates automatically before they expire. Since Let’s Encrypt certificates last for 90 days, it’s highly advisable to take advantage of this feature. You can test automatic renewal for your certificates by running this command:

sudo certbot renew --dry-run

Replace Default Apache Website

Step by Step instructions on replacing default Apache website with Custom page.

Now, after navigating to you’ll see Apache default website.

You can find Apache default index.html file in /var/www/html path.
Change it with the html code for your website, for example:

Now will look like this: