HTTPS is no longer optional but a necessity: browsers mark sites without SSL as “Not secure”, and Google uses HTTPS as a ranking signal. In this guide we'll use Certbot to install a free Let's Encrypt certificate on your Nginx or Apache server and configure automatic renewal.
Requirements
- A VDS/dedicated server running Ubuntu or Debian, with sudo privileges.
- A website running on Nginx or Apache.
- Your domain's (and the
wwwsubdomain's) A record pointing to your server's IP address. - Ports 80 and 443 open in the firewall.
If you use cPanel, Plesk or DirectAdmin, you don't need these steps; the panels install and renew Let's Encrypt certificates automatically.
Step 1: Install Certbot
Install Certbot together with the plugin for your web server:
# If you use Nginx
sudo apt update
sudo apt install -y certbot python3-certbot-nginx
# If you use Apache
sudo apt update
sudo apt install -y certbot python3-certbot-apacheStep 2: Allow HTTPS in the firewall
sudo ufw allow 'Nginx Full' # For Nginx
sudo ufw allow 'Apache Full' # For ApacheStep 3: Obtain and install the certificate
Certbot reads your web server configuration and adds the certificate automatically:
# Nginx
sudo certbot --nginx -d alanadiniz.com -d www.alanadiniz.com
# Apache
sudo certbot --apache -d alanadiniz.com -d www.alanadiniz.comOn the first run you'll be asked for your email address (for expiry notices) and must accept the terms of service. When the process completes, Certbot updates the configuration so that HTTP requests are automatically redirected to HTTPS.
If you get a “Challenge failed” error, check that your domain's DNS record points to the correct IP and that port 80 is reachable from outside. DNS changes can take a few hours to propagate.
Step 4: Test automatic renewal
Let's Encrypt certificates are valid for 90 days. The Certbot package installs a systemd timer that renews certificates automatically. Verify that it is working:
systemctl list-timers | grep certbot
sudo certbot renew --dry-runIf the --dry-run command completes without errors, renewal will work smoothly.
Step 5: Verify the installation
Open https://alanadiniz.com in your browser and check the padlock icon. To view certificate details from the command line:
sudo certbot certificatesBonus: Security headers
After installing SSL, you can add the HSTS header in Nginx to make browsers always connect to your site over HTTPS. Add the following line to the relevant server block:
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;sudo nginx -t && sudo systemctl reload nginxConclusion
Your site is now protected by a free SSL certificate that renews automatically. Let's Encrypt SSL is provided free and automatically on all MerkezHost hosting plans.
Frequently Asked Questions
How long is a Let's Encrypt certificate valid?
Let's Encrypt certificates are valid for 90 days. Certbot renews the certificate automatically before it expires.
Is there a difference between free SSL and paid SSL?
The encryption strength is the same. Paid certificates offer additional features such as organisation validation (OV/EV), warranties and support.
