Skip to main content

Install Apache HTTPS on Ubuntu 26.04 LTS Resolute Raccoon

In this simple step-by-step guide, we will see how to Install Apache on Ubuntu 26.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, performance, and ease of configuration. In this guide, we will see how to install and configure the latest Apache packages on Ubuntu 26.04, the cutting-edge release 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 26.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 26.04

To install Apache on Ubuntu 26.04, use the apt command. The official repositories include the latest stable builds optimized for modern hardware:

sudo apt install apache2

The system will download and install Apache and its dependencies.

Step 3: Configure the Firewall (UFW)

On Ubuntu 26.04, it is highly recommended to configure the Uncomplicated Firewall (UFW) to allow web traffic. Apache registers itself with UFW upon installation. To allow both HTTP (port 80) and HTTPS (port 443) traffic, run:

sudo ufw allow 'Apache Full'
sudo ufw status

This ensures your server is securely accessible from the outside.

Step 4: 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 for Ubuntu 26.04.

Step 5: 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

    sudo mkdir -p /var/www/html/example.com
    sudo chown -R $USER:$USER /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.

    sudo nano /etc/apache2/sites-available/example.com.conf
  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:

    sudo a2ensite example.com.conf
    sudo a2dissite 000-default.conf
  5. Restart Apache to apply the changes:

    sudo systemctl restart apache2

HTTPS with free Let's Encrypt SSL certificates

Now that we have installed Apache on Ubuntu 26.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:

sudo apt install certbot python3-certbot-apache

Let's create the Apache2 configuration:

sudo certbot --apache

Let's test the certificate renewal:

sudo certbot renew --dry-run

Let's check that the scheduled Cron process for renewal is present (or handled via systemd timers in newer releases):

systemctl list-timers | grep 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 & HTTP/2

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.

Enabling Modern Protocols (HTTP/2)

To significantly improve performance on modern browsers, you can enable the HTTP/2 module included in the Ubuntu 26.04 Apache package:

sudo a2enmod http2
sudo systemctl restart apache2

Apache service management

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

  • sudo systemctl start apache2: starts the Apache service
  • sudo systemctl stop apache2: stops the Apache service
  • sudo systemctl restart apache2: 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 systemctl restart apache2 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 sudo a2enmod module-name and restart Apache.

Conclusion

By following these simple steps, we have installed the latest version of Apache on Ubuntu 26.04. If you need further assistance or want to optimize your configuration with the newest technology stacks, 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.