How to Install a Free SSL Certificate on Ubuntu Using Let's Encrypt and Certbot

thumbnail

How to Install a Free SSL Certificate on Ubuntu Using Let's Encrypt and Certbot

Securing your website with HTTPS is no longer optional. A valid SSL certificate protects user data, improves search engine rankings, increases customer trust, and removes "Not Secure" warnings from modern browsers.

One of the easiest and most popular ways to enable HTTPS is by using Let's Encrypt, a free Certificate Authority, together with Certbot, an open-source tool that automates SSL certificate installation and renewal.

In this guide, you'll learn how to install a free SSL certificate on Ubuntu servers running Apache or NGINX using Certbot.

Prerequisites

Before installing your SSL certificate, make sure you have:

  • An Ubuntu 20.04, 22.04, or 24.04 server.
  • Root or sudo access.
  • A registered domain pointing to your server's public IP.
  • Apache or NGINX already installed.
  • Ports 80 and 443 open in your firewall.

Open Required Firewall Ports

sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw reload

Step 1: Update Your Ubuntu Server

Always begin by updating your packages to ensure your server is running the latest security updates.

sudo apt update sudo apt upgrade -y

Step 2: Install Certbot

Certbot is available directly from Ubuntu's official repositories.

For Apache

sudo apt install certbot python3-certbot-apache -y

For NGINX

sudo apt install certbot python3-certbot-nginx -y

After installation, verify that Certbot is available.

certbot --version

Step 3: Generate Your SSL Certificate

Once Certbot is installed, request an SSL certificate for your domain.

Apache

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

NGINX

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

Replace example.com with your actual domain name.

During installation, Certbot will ask you to:

  • Enter your email address.
  • Accept the Let's Encrypt Terms of Service.
  • Choose whether to redirect all HTTP traffic to HTTPS.

Selecting automatic HTTP to HTTPS redirection is recommended for most production websites.

Step 4: Verify SSL Installation

After installation completes successfully, open your website using HTTPS.

https://yourdomain.com

You should see a secure padlock icon in your browser.

You can also verify installed certificates using:

sudo certbot certificates

Step 5: Enable Automatic SSL Certificate Renewal

Let's Encrypt SSL certificates are valid for 90 days. Fortunately, Certbot can automatically renew your certificates before they expire, ensuring uninterrupted HTTPS protection.

Check whether the Certbot renewal service is active:

systemctl status certbot.timer

To test the renewal process without making any changes, run a dry run:

sudo certbot renew --dry-run

If the command completes successfully, your server is configured to renew SSL certificates automatically.

Step 6: Force HTTPS Redirection

Redirecting all visitors from HTTP to HTTPS ensures encrypted communication and helps improve SEO rankings. If you selected automatic redirection during the Certbot installation, this step has already been completed.

If not, update your Apache or NGINX configuration to permanently redirect all HTTP traffic to HTTPS.

Step 7: Improve Website Security with HSTS

HTTP Strict Transport Security (HSTS) instructs browsers to always use HTTPS when accessing your website, preventing protocol downgrade attacks.

Apache Configuration

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

NGINX Configuration

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

After updating your configuration, restart your web server.

Common SSL Installation Issues

Domain Does Not Point to the Server

Verify that your domain's DNS A record points to your server's public IP address before requesting a certificate.

Port 80 Is Blocked

Let's Encrypt validates your domain over HTTP. Make sure port 80 is open in your firewall and cloud security settings.

Certificate Renewal Failed

If renewal fails, test the configuration using the dry-run command and review the Certbot logs located in /var/log/letsencrypt/.

Mixed Content Warning

If your browser still shows "Not Secure," check that your website loads all images, CSS files, JavaScript, and fonts over HTTPS instead of HTTP.

Benefits of Using Let's Encrypt

  • Free SSL certificates for unlimited domains.
  • Automatic certificate renewal.
  • Trusted by all major browsers.
  • Improves Google search rankings.
  • Encrypts communication between visitors and your server.
  • Builds trust by displaying the secure HTTPS padlock.

Frequently Asked Questions

Is Let's Encrypt really free?

Yes. Let's Encrypt provides SSL certificates at no cost and is trusted by all modern web browsers.

How long is a Let's Encrypt certificate valid?

Each certificate is valid for 90 days, but Certbot can renew it automatically before expiration.

Does SSL improve SEO?

Yes. HTTPS is a confirmed Google ranking signal and helps improve user trust, website security, and search engine visibility.

Can I use Let's Encrypt with Apache and NGINX?

Yes. Certbot officially supports both Apache and NGINX, making SSL installation quick and straightforward.

Can I secure multiple domains?

Absolutely. Certbot supports multiple domains and subdomains by specifying multiple -d parameters when requesting a certificate.

Need Help Securing Your Server?

Installing an SSL certificate is an important step toward building a secure and reliable website. If you need assistance configuring HTTPS, deploying web applications, optimizing Ubuntu servers, or managing Apache and NGINX environments, the experts at Hayatics are here to help.

We specialize in backend development, server administration, cloud deployments, API integrations, DevOps, and AI-powered solutions for businesses of all sizes.

Contact Hayatics today to secure your infrastructure and keep your web applications running safely and efficiently.