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

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

Securing your website with SSL/TLS is crucial for protecting user data and improving trust. In this guide, we’ll walk you through the process of setting up Let’s Encrypt SSL on Ubuntu 24.04 with Apache. This setup is straightforward and free, courtesy of Certbot.

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

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

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 nano /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!

By following these SEO best practices and incorporating the keyword naturally throughout your post, you’ll improve your chances of ranking higher in search engine results.

Leave a Reply

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