Apache HTTP Server is one of the most popular web servers in the world. This guide installs and starts Apache on Ubuntu 24.04 LTS and verifies that it is serving content correctly.
Tested and valid on:
- Ubuntu 24.04 LTS
Prerequisites
- Ubuntu 24.04 LTS server
- A user with sudo privileges
- UFW firewall configured
Step 1 – Update Package Lists
Refresh package index:
sudo apt update
Step 2 – Install Apache
Install from the Ubuntu repository:
sudo apt install apache2 -y
Step 3 – Allow Apache Through UFW
Permit HTTP and HTTPS:
sudo ufw allow 'Apache Full'
sudo ufw status
Step 4 – Start and Enable Apache
Start and enable on boot:
sudo systemctl start apache2
sudo systemctl enable apache2
Step 5 – Verify Apache Is Running
Check service status:
sudo systemctl status apache2
Visit http://your_server_ip — you should see the Apache Ubuntu Default Page.
Step 6 – Key Directory Structure
Important Apache paths:
/etc/apache2/apache2.conf— main config/etc/apache2/sites-available/— virtual host files/etc/apache2/sites-enabled/— active sites/var/www/html/— default document root/var/log/apache2/— logs
Step 7 – Useful Apache Commands
Enable and disable modules and sites:
sudo a2enmod rewrite # enable a module
sudo a2dismod rewrite # disable a module
sudo a2ensite mysite.conf # enable a virtual host
sudo a2dissite 000-default.conf
Step 8 – Test Configuration
Check for syntax errors:
sudo apache2ctl configtest
Conclusion
Apache is now installed on Ubuntu 24.04 LTS. Configure virtual hosts for your domains and add SSL with Let’s Encrypt to serve traffic over HTTPS.