Skip to main content

Install Apache HTTPS on Ubuntu 24.04 LTS Noble Numbat

In this simple step-by-step guide, we will see how to Install Apache on Ubuntu 24.04 and configure the Web Server. The tutorial is designed for users with basic knowledge of computer science and Linux.

Introduction

Apache is one of the most popular web servers in the world, known for its reliability and ease of configuration. In this guide, we will see how to install and configure Apache on Ubuntu 24.04, one of the latest releases of this popular Linux distribution.

Prerequisites

Before starting, make sure you have:

Step 1: Update the System

First, it is important to update the Ubuntu 24.04 packages to ensure you have the latest and most secure versions. To prevent your business growth from being slowed down by bottlenecks or fragile and complex architectures in the future, consider our design of highly scalable, intrinsically secure, and optimized IT infrastructures for Ubuntu server environments. Open the terminal and type:

sudo apt update
sudo apt upgrade

These commands update the package index and install available updates.

Step 2: Install Apache on Ubuntu 24.04

To install Apache on Ubuntu 24.04, use the apt command:

sudo apt install apache2

The system will download and install Apache and its dependencies.

Step 3: Verify the Installation

To verify that Apache was installed correctly and that the service is active, you can use the following command:

sudo systemctl status apache2

You should see an output similar to "active (running)". You can also verify this by opening a web browser and navigating to your server's IP address. You should see the Apache welcome page.

Step 4: Virtual Host Configuration

Virtual Hosts allow you to host multiple websites on a single Apache server. To configure a Virtual Host, follow these steps:

  1. Create the directory for the files that will be served by Apache

    mkdir /var/www/html/example.com
  2. Create a Virtual Host configuration file with an appropriate name, for example example.com.conf, in the /etc/apache2/sites-available directory.

    nano /etc/apache2/sites-available/example.com
  3. Add the following content to the configuration file, replacing example.com with your domain name:

    <VirtualHost *:80>
    	ServerName example.com
    	ServerAlias www.example.com
    	DocumentRoot /var/www/html/example.com         
    	<Directory /var/www/html/example.com>
    		Options Indexes FollowSymLinks
    		AllowOverride All
    		Require all granted
    	</Directory>
    </VirtualHost>
  4. Enable the Virtual Host using the a2ensite command or by creating a symbolic link to the configuration file in the /etc/apache2/sites-enabled directory:

    sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enabled/example.com.conf
  5. Restart Apache to apply the changes:

    sudo service apache2 restart

HTTPS with free Let's Encrypt SSL certificates

Now that we have installed Apache on Ubuntu 24.04, thanks to the excellent Let's Encrypt, it is possible to generate SSL/TLS certificates that are universally recognized, secure, and free.

It is necessary to configure the DNS name of the website we are going to host in order to reach the IP of our server.

DNS configuration example

To configure the DNS, you need to access your provider's panel and register a name like this:

example.com                  A      1.1.1.1

Let's install Let's Encrypt and generate the SSL and TLS certificates:

apt install certbot python3-certbot-apache

Let's create the Apache2 configuration:

certbot --apache

Let's test the certificate renewal:

certbot renew --dry-run

Let's check that the scheduled Cron process for renewal is present:

cat /etc/cron.d/certbot

If there were no problems resolving our domain, our virtual hosts will respond in HTTPS, returning the famous "green padlock" on the browser.

Guarantee the Absolute Operational Continuity of your Services

Do you have a paralyzing fear of service interruptions during the update, migration, or scaling of your infrastructure? Our experts will support you every step of the way, breaking down every technological obstacle with bottleneck-free architectures.

Discover our Zero-Downtime DevOps Migration services

Apache Configurations

Apache configuration mainly takes place through the files in /etc/apache2/. Here are some of the most important files:

  • /etc/apache2/apache2.conf: The main configuration file.
  • /etc/apache2/sites-available/: Directory containing the configurations of the available sites.
  • /etc/apache2/sites-enabled/: Directory containing the configurations of the active sites.

To enable a site, use the a2ensite command followed by the name of the site's configuration file. To disable it, use a2dissite.

Apache service management

You can use the following commands to manage the Apache service:

  • sudo service apache2 start: starts the Apache service
  • sudo service apache2 stop: stops the Apache service
  • sudo service apache2 restart: restarts the Apache service
  • sudo systemctl enable apache2: enables the automatic start of Apache on system boot
  • sudo systemctl disable apache2: disables the automatic start of Apache on system boot

Useful Resources

Frequently Asked Questions (FAQ)

1. How can I restart Apache?

Use the sudo service apache2 restart command.

2. How can I view the Apache logs?

The Apache logs are located in the /var/log/apache2/ directory. The main files are access.log and error.log.

3. Can I install additional modules for Apache?

Yes, you can install additional modules using the sudo apt install module-name command. Then enable the module with a2enmod module-name and restart Apache.

Conclusion

By following these simple steps, we have installed Apache on Ubuntu 24.04. If you need further assistance or want to optimize your configuration, do not hesitate to contact us. Our team of experts is ready to help you.

Looking for Apache support?

We've got you covered! Get a free 30-minute analysis for your system, protect yourself and request our management of guaranteed "Zero-Downtime" migrations from On-Premise to Cloud environments with the best architecture for Apache Web server today.

Add new comment

Comment

  • Allowed HTML tags: <br> <p> <code class="language-*"> <pre>
  • Lines and paragraphs break automatically.
  • Only images hosted on this site may be used in <img> tags.