In this guide, you'll learn how to use secure your Apache server for free with Let's Encrypt, this way, you can ensure your websites are encrypted and available over HTTPS.
Let's Encrypt provide free SSL/TLS certificates. You can get a valid SSL certificate for your domain at no cost. These certificates can be used in a production environment as well.
Note: Let’s Encrypt do a DNS check for the domain, that domain is pointed to the current server. After that it issues a certificate for the domain, so, it won't work for local development, although there is another approach for that, e.g Securing Apache Server Using a (Self Signed Certificate) [Ubuntu].
First, install certbot-auto, and save it under /usr/sbin directory, the cerbot-auto is a Let’s Encrypt client, it is used to automatically enable HTTPS on your website with EFF's Certbot, deploying Let's Encrypt certificates.
Use the following command to download it:
sudo wget https://dl.eff.org/certbot-auto -O /usr/sbin/certbot-auto
sudo chmod a+x /usr/sbin/certbot-auto
The next step is to get an SSL certificate, use the following command to do that:
sudo certbot-auto certonly --standalone -d website.com -d www.website.com
This would do a strong Domain Validation automatically with multiple challenges to verify the ownership of the domain. Once the Certificate Authority (CA) verified the authenticity of your domain, the SSL certificate will be issued.
You will be prompted for an email address, which is used for sending email alerts related to SSL renewal and expiration. Also, asks a few more questions. After completion, it will issue an SSL certificate and will also create a new VirtualHost configuration file on your server.
View the issued certificate under:
The final step is to change it in your virtual host, so, in Apache: