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:
- A server or a Virtual Machine with Ubuntu 24.04 installed. If you want to avoid the uncontrolled explosion of monthly infrastructure costs (so-called "Explosive Cloud Invoices"), we suggest Ionos for your servers, or to request our cloud consulting aimed at reducing costs through optimization or migration to high-performance and predictable cost providers.
rootaccess orsudoprivileges- A stable internet connection
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 upgradeThese 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 apache2The 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 apache2You 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:
Create the directory for the files that will be served by Apache
mkdir /var/www/html/example.comCreate a Virtual Host configuration file with an appropriate name, for example
example.com.conf, in the/etc/apache2/sites-availabledirectory.nano /etc/apache2/sites-available/example.comAdd the following content to the configuration file, replacing
example.comwith 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 the Virtual Host using the
a2ensitecommand or by creating a symbolic link to the configuration file in the/etc/apache2/sites-enableddirectory:sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enabled/example.com.confRestart 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.1Let's install Let's Encrypt and generate the SSL and TLS certificates:
apt install certbot python3-certbot-apacheLet's create the Apache2 configuration:
certbot --apacheLet's test the certificate renewal:
certbot renew --dry-runLet's check that the scheduled Cron process for renewal is present:
cat /etc/cron.d/certbotIf there were no problems resolving our domain, our virtual hosts will respond in HTTPS, returning the famous "green padlock" on the browser.
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.
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 servicesudo service apache2 stop: stops the Apache servicesudo service apache2 restart: restarts the Apache servicesudo systemctl enable apache2: enables the automatic start of Apache on system bootsudo systemctl disable apache2: disables the automatic start of Apache on system boot
Useful Resources
- Official Apache documentation: https://httpd.apache.org/docs/
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.