Easiest way to install letsencrypt on Linux
(: July 31, 2017)
Install Letsencrypt on Linux: Today i would like to show you the easiest and quickest way to install Letsencrypt on Linux. The process involve few steps and is really automated. The aim here is to use certbot bootstrap script by EFF to request for SSL certificate for your website from Let’s Encrypt.
Certbot is an easy-to-use client that fetches a certificate from Let’s Encrypt-an open certificate authority launched by the EFF, Mozilla, and others and deploys it to a web server.
Below are the steps to follow:
- Download certbot-auto script
wget https://dl.eff.org/certbot-auto -P /usr/local/bin
Make the script executable:
chmod a+x /usr/local/bin/certbot-auto
Before you can request for ssl certificate, open port 443 on firewall, This demonstration assumes you are running CentOS 7.x whose firewall system is firewalld. If you have other systems like Ubuntu or Debian, firewall system might be different.
firewall-cmd --add-service https --permanent firewall-cmd --reload
Now request for ssl certificate:
certbot-auto certonly -d mydomain.com -d www.mydomain.com
As you make first request, the script will install required packages/dependencies and setup virtual environment.
Note that you need active dns A record for the domain specified. For www.mydomain.com, this can be a CNAME record.
Answer few questions on the prompt and in no a time you have your ssl certificate and private key. Default location for this is: /etc/letsencrypt/live
Automated renewal using –pre-hook and –post-hook
- For nginx # /usr/local/bin/certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start" - For apache # /usr/local/bin/certbot-auto renew --pre-hook "systemctl stop apache2" --post-hook "systemctl start apache2"
To force manual renewal:
certbot renew --force-renewal
If you would like to use cron jobs, your crontab should have a line similar to one below:
15 3 * * * usr/local/bin/certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start"