How to protect Apache with Let's Encrypt on Ubuntu 16.04

Introduction

This tutorial will show you how to set up a TLS/SSL certificate for Let's Encrypt on an Ubuntu 16.04 server running Apache as a web server.

The SSL certificate is used in the web server to encrypt the traffic between the server and the client, providing additional security for users accessing the application. Let's Encrypt provides an easy way to obtain and install trusted certificates for free.

prerequisites

To complete this guide, you need:

When you are ready to move on, log in to your server with a sudo-enabled account.

Step 1-Install Let's Encrypt client

Let us obtain the encryption certificate through the client software running on the server. The official client is called Certbot, and its developers maintain their own Ubuntu software repository using the latest version. Because Certbot is under such active development, it is worthwhile to use this repository by default to install newer versions than those provided by Ubuntu.

First, add the repository:

sudo add-apt-repository ppa:certbot/certbot

You need to press ENTER to accept. Then, update the package list to get package information for the new repository:

sudo apt-get update

Finally, install Certbot from the new repository using apt-get:

sudo apt-get install python-certbot-apache

The certbotLet's Encrypt client is ready to use.

Step 2-Set up SSL certificate

Using Certbot to generate SSL certificates for Apache is very simple. The client will automatically obtain and install a new SSL certificate, which is valid for the domain provided as a parameter.

To perform an interactive installation and obtain a certificate covering only a single domain, run the following certbot command, where example.com is your domain:

sudo certbot --apache -d example.com

If you want to install a single certificate that is valid for multiple domains or subdomains, you can pass them as additional parameters to the command. The first domain name in the parameter list will be the basic domain used by Let's Encrypt to create the certificate, so we recommend that you make the naked top-level domain the first in the list, followed by any other subdomains or aliases:

sudo certbot --apache -d example.com -d www.example.com

For this example, the Basic domain will be example.com.

If you have multiple virtual hosts, you should run certbot once for each virtual host to generate a new certificate for each virtual host. You can distribute multiple domains and subdomains across virtual hosts in any way.

Once the dependencies are installed, you will be provided with a step-by-step guide for custom certificate options. You will be asked to provide an email address for lost key recovery and notification. You can choose to enable http and https access, or force all redirect requests to https. Unless you specifically need unencrypted http traffic, it is generally safest to request https.

After the installation is complete, you should be able to find the generated certificate file in /etc/letsencrypt/live. You can verify the status of the SSL certificate using the following link (don’t forget to replace example.com with your basic domain):

https://www.ssllabs.com/ssltest/analyze.html?d=example.com&latest

You should now be able to access your website using the https prefix.

Step 3-Verify that Certbot automatically renews

Let's Encrypt's certificate can only last for 90 days. However, the certbot package we installed solves this problem for us by running certbot renew and using the systemd timer to run twice a day. On non-system distributions, this feature is provided by the cron script placed in /etc/cron.d. This task runs twice a day and will renew any certificates within 30 days of expiration.

To test the update process, you can perform the following operations with certbot:

sudo certbot renew --dry-run

If you do not see any errors, then you have completed the setup. If necessary, Certbot will renew your certificate and reload Apache to pick up the changes. If the automatic renewal process fails, our encryption will send a message to the email you specify and warn you when your certificate is about to expire.

in conclusion

In this guide, we learned how to install a free SSL certificate from Let's Encrypt to protect websites hosted with Apache. We recommend that you check the official Let's Encrypt Blog from time to time for important updates, and read Certbot Documentation for more detailed information about the Certbot client.

For more Ubuntu tutorials, please go to [Tencent Cloud + Community] (https://cloud.tencent.com/developer?from=10680) to learn more.


Reference: "How To Secure Apache with Let's Encrypt on Ubuntu 16.04"

Recommended Posts

How to protect Apache with Let's Encrypt on Ubuntu 16.04
Protect Apache with Let's Encrypt on Ubuntu 20.04
Protect Apache with Let's Encrypt on CentOS 8
How to install Apache on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to use Let's Encrypt to protect Nginx on CentOS 8
How to install Apache Kafka on Ubuntu 18.04
How to install Apache Maven on Ubuntu 20.04
How to install Apache Tomcat 8 on Ubuntu 16.04
How to install Prometheus with Docker on Ubuntu 14.04
How to manage Jenkins with Rancher on Ubuntu 14.04
How to play happily with Python3 on Ubuntu
How to configure Apache content caching on Ubuntu 14.04
How to start a blog with Hexo on Ubuntu 14.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to upgrade to PHP 7 on Ubuntu 14.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to deploy Django on Ubuntu 14.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to secure Nginx on Ubuntu 14.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to uninstall software on Ubuntu
How to install Nginx on Ubuntu 16.04
How to install Apache on CentOS 8
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04