How to Set Up Let’s Encrypt SSL on Ubuntu 24.04 with Apache

Learn how to set up Let’s Encrypt SSL on Ubuntu 24.04 with Apache in this comprehensive guide. Secure your website with a free SSL certificate and enhance your site’s security with step-by-step instructions.

Securing your website with SSL/TLS is crucial for protecting user data and improving trust among your visitors. When a website uses SSL/TLS, it encrypts the data exchanged between the server and the user’s browser, making it significantly more difficult for malicious actors to intercept sensitive information such as login credentials, payment details, or personal information. Furthermore, a secure connection is increasingly important for SEO, as search engines prioritize HTTPS-enabled websites over those that are not secure. This enhanced security not only protects your users but also fosters a sense of confidence, encouraging them to interact with your site without fear of data breaches.

In this guide, we’ll walk you through the process of setting up Let’s Encrypt SSL on Ubuntu 24.04 with Apache. Let’s Encrypt provides a free, automated, and open Certificate Authority, allowing you to obtain an SSL/TLS certificate with minimal effort. The process is straightforward and efficient, thanks to Certbot, which simplifies certificate installation and renewal. By following this guide, you will learn how to secure your website, ensuring that your users’ data is protected while also enhancing your website’s credibility and search engine visibility.

Also: Ubuntu CodeIgniter Setup: A Step-by-Step Installation Guide


Table of Contents


Prerequisites

  • Ubuntu 24.04 LTS installed and running.
  • A registered domain name pointing to your server.
  • Apache web server installed.
  • Root or Sudo Privileges on your server.

Step 1: Update Your System

Before starting, make sure your system is up-to-date. Open a terminal and run:

sudo apt update
sudo apt upgrade -y

Step 2: Install Apache (If Not Already Installed)

If Apache is not yet installed, you can do so with:

sudo apt install apache2 -y

For more information on installing Apache, see the official Apache documentation.


Step 3: Install Certbot and the Apache Plugin

Certbot helps in obtaining and managing SSL certificates from Let’s Encrypt. Install Certbot and the Apache plugin using:

sudo apt install certbot python3-certbot-apache -y

Learn more about Certbot and its Apache plugin on the Certbot website.


Step 4: Configure Apache

Prepare your Apache configuration for SSL.

Create or Update Your Virtual Host File

Create a configuration file for your site, e.g., example.com.conf:

Add the following configuration:

sudo vim /etc/apache2/sites-available/example.com.conf 
<VirtualHost *:80> 
ServerAdmin webmaster@example.com 
ServerName example.com 
ServerAlias www.example.com 
DocumentRoot /var/www/html 
ErrorLog ${APACHE_LOG_DIR}/error.log 

CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost>

For more details on Apache modules, visit the Apache Modules documentation.


Enable the Site and Required Modules

Enable the site and necessary modules with:

sudo a2ensite example.com.conf 
sudo a2enmod rewrite 
sudo a2enmod ssl

Test and Reload Apache.

Verify the Apache configuration:

sudo apache2ctl configtest
sudo systemctl reload apache2

Step 5: Obtain and Install an SSL Certificate

Use Certbot to obtain and configure your SSL certificate:

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

Follow the prompts to provide your email address and agree to the terms of service. Certbot will configure Apache to use SSL.


Step 6: Verify SSL Installation

Check your website using https:// to ensure SSL is working. You should see a padlock icon in the browser’s address bar, indicating that the connection is secure.


Step 7: Set Up Auto-Renewal

Let’s Encrypt certificates are valid for 90 days. Set up a cron job to renew them automatically:

Open the cron job editor:

sudo crontab -e

Add the following line to check for renewal twice daily:

0 */12 * * * certbot renew --quiet

Save and exit. This job will renew your certificate and reload Apache if necessary.


Conclusion

You’ve now set up Let’s Encrypt SSL on Ubuntu 24.04 with Apache, securing your site with HTTPS. This enhances both security and trustworthiness. If you have any questions or run into issues, leave a comment below!

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments (

)

  1. Paul Tammes

    Marvelous, I love it when a howto just works!

    1. Sam Galope

      Thank you so much for the kind words! I’m thrilled to hear the guide worked perfectly for you. If you have any other projects or questions, feel free to reach out—or check out some of the other guides on my site.

  2. Corbridge

    Thanks – Enjoyed this post, how can I make is so that I receive an email sent to me whenever there is a fresh article?

    1. Sam Galope

      I’m glad you enjoyed the post! To receive email notifications for new articles, you can typically subscribe to the blog’s newsletter or RSS feed. If you’re on the website, there may be an option to sign up for updates. Let me know if you need any help finding that!

  3. Barks

    Hey there! I’ve been following your web site for a while now and finally got the courage to go ahead and give you a shout out from Houston Texas! Just wanted to say keep up the excellent job!

    1. Sam Galope

      Hey there, thanks for reaching out from Houston! I really appreciate your support and kind words. It’s great to know you’ve been following the site, and I’ll definitely keep up the hard work. Thanks again!

  4. DiFrancisco

    Hi this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding experience so I wanted to get advice from someone with experience. Any help would be enormously appreciated!

    1. Sam Galope

      Great question! Most blogs these days use WYSIWYG (What You See Is What You Get) editors, which allow you to write and format content without needing to know HTML. Platforms like WordPress, Wix, and others make it easy to create a blog with drag-and-drop features and visual editing tools.

      However, if you ever want more control over your blog’s design or functionality, learning some basic HTML and CSS can be very helpful. It’s not required for starting a blog, but it’s a nice skill to have down the line. Let me know if you need recommendations for blog platforms or want to learn more about coding!

  5. Foye

    Definitely, what a great blog and illuminating posts, I will bookmark your site.Have an awsome day!

    1. Sam Galope

      Thank you for the kind words! I’m glad you’re enjoying the blog. I appreciate you bookmarking the site—have an awesome day too!

  6. Britt

    Keep this going please, great job!

    1. Sam Galope

      Thank you so much! I’m glad you’re enjoying the content. To stay updated with more posts, be sure to check out our subscription page here. Appreciate your support!