Installing Apache HTTPS on Ubuntu 24.04 LTS Noble Numbat
In this simple step-by-step guide, we see how to Install Apache on Ubuntu 24.04 and configure the Web Server. The tutorial is designed for users with basic computer and Linux knowledge.
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 versions of this popular Linux distribution.
Prerequisites
Before you start, make sure you have:
- A server or Virtual Machine with Ubuntu 24.04 installed
Root
access orsudo
privileges- A stable Internet connection
Step 1: Update the System
First, it is important to update the Ubuntu 24.04 packages to make sure you have the latest and most secure versions. 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 has been properly installed and that the service is active, you can use the following command:
sudo systemctl status apache2
You should see output similar to "active (running)." You can also check by opening a Web browser and navigating to your server's IP address. You should see the Apache welcome page.
Step 4: Configuring Virtual Hosts.
Virtual Hosts allow you to host multiple websites on a single Apache server. To configure a Virtual Host, follow these steps:
Create the directory for the files that will be served by Apache
mkdir /var/www/html/example.com.
Create a Virtual Host configuration file with an appropriate name, such as
example.com.conf
, in the/etc/apache2/sites-available
directory.nano /etc/apache2/sites-available/example.com.
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>
Enable 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
Restart Apache to apply the changes:
sudo service apache2 restart
HTTPS with free SSL certificates Let's Encrypt
Now that we have installed Apache on Ubuntu 24.04, thanks to the excellent Let's Encrypt, you can generate SSL/TLS certificates, which are universally recognized, secure and free
We need to configure the DNS name of the website we are going to host so that it reaches the IP of our server
DNS configuration example
To configure DNS, we need to access our provider's panel and register a name like this
example.com A 1.1.1.1
We 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
We test the renewal of certificates
certbot renew --dry-run
We 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" to us on the browser
Apache Configurations
The configuration of Apache is mainly done through 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 where the configurations of available sites are located./etc/apache2/sites-enabled/
: Directory where the configurations of active sites are located.
To enable a site, use the a2ensite
command followed by the name of the site configuration file. To disable it, use a2dissite
.
Managing the Apache service
You can use the following commands to manage the Apache service:
sudo service apache2
start: starts the Apache servicesudo service apache2
stop: stops the Apache servicesudo service apache2 rest
art: restarts the Apache servicesudo systemctl enable apache2
: enables Apache to start automatically at system startupsudo systemctl disable apache2
: disables the automatic startup of Apache at system startup
Useful resources
- Official Apache documentation: https://httpd.apache.org/docs/
Frequently Asked Questions (FAQ)
1. How can I restart Apache?
Use the command sudo service apache2 restart
.
2. How can I view the Apache logs?
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 command sudo apt install module-name
. 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, please feel free to contact us. Our team of experts is ready to help you.
Looking for Apache support?
We've got it covered! Free 30m analysis for your system, request a dedicated Apache Consultation now!