How to Setup Let’s Encrypt SSL for Apache on Ubuntu 18.04

Hakan Bayraktar
2 min readOct 12, 2019

--

1-Apache Vhost Configuration

A domain name registered and pointed to your server’s public IP address. For this tutorial, we use redhillinteractive.com and www.redhillinteractive.com which are pointed to our server. (you should use yourselves domain)

vi /etc/apache2/sites-enabled/wordpress.conf

<VirtualHost *:80> ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName redhillinteractive.com
ServerAlias www.redhillinteractive.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options -Indexes
</Directory>
</VirtualHost>

2-Add Certbot PPA and Install Certbot

You’ll need to add the Certbot PPA to your list of repositories.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache

3-Install Let’s Encrypt Client

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

4 — Get a SSL Certificate

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

5 — Configure SSL Auto-Renew

You can test automatic renewal for your certificates by running this command:

sudo certbot renew --dry-run

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

0 2 * * * sudo /usr/sbin/certbot-auto -q renew

5 — Check your website’s

To confirm that your site is set up properly, visit https://yourwebsite.com/ in your browser and look for the lock icon in the URL bar.

If you want to check that you have the top-of-the-line installation, you can head to https://www.ssllabs.com/ssltest/

--

--