Learn how to install Apache on Ubuntu 26.04 LTS with this beginner friendly step by step guide. Install Apache, configure a virtual host, enable the firewall, and host your first website in minutes.
Apache is one of the most popular web servers available for Linux. It is free, reliable, and works well for everything from small personal websites to large production applications. Ubuntu 26.04 includes Apache in its official package repository, so installation only takes a few minutes.
Prerequisites
Before you begin, make sure you have:
-
An Ubuntu 26.04 dedicated server
-
A user with sudo privileges
-
An internet connection
Learn how to install Apache on Ubuntu 26.04 LTS step-by-step
Step 1: Update the Package List
First, refresh your package index so Ubuntu knows about the latest available packages.
sudo apt update
This command does not install anything. It simply updates the package information.
Step 2: Install Apache
Install Apache using the default Ubuntu repository.
sudo apt install apache2 -y
Ubuntu downloads Apache along with all required dependencies and installs them automatically. Apache is then started as a system service.
Step 3: Check the Apache Version
After installation, verify that Apache is installed correctly.
apachectl -v
You should see output similar to:
Server version: Apache/2.4.x (Ubuntu)
The exact version may differ depending on the latest security updates available for Ubuntu 26.04.
Step 4: Check the Apache Service Status
Confirm that Apache is running.
sudo systemctl status apache2
If everything is working, you'll see:
Active: active (running)
Press Q to exit the status screen.
Step 5: Enable Apache at Boot
Apache normally starts automatically after installation, but you can ensure it starts after every reboot.
sudo systemctl enable apache2
Step 6: Allow HTTP and HTTPS Through the Firewall
If UFW is enabled, allow web traffic.
sudo ufw allow 'Apache Full'
This opens:
-
Port 80 (HTTP)
-
Port 443 (HTTPS)
You can verify the firewall rules with:
sudo ufw status
Step 7: Test Apache
Find your server's IP address.
hostname -I
Example output:
192.168.1.100
Open your browser and visit:
http://YOUR_SERVER_IP
If Apache is working correctly, you'll see the default Apache2 Ubuntu Default Page.
You can also test from the terminal.
curl http://localhost
If HTML content is returned, Apache is serving web pages correctly.
Step 8: Create a Sample Website
Create a simple HTML page.
sudo nano /var/www/html/index.html
Paste the following content:
<!DOCTYPE html>
<html>
<head>
<title>Apache on Ubuntu 26.04</title>
</head>
<body>
<h1>Apache is Working!</h1>
<p>Your web server has been installed successfully.</p>
</body>
</html>
Save the file and exit.
Refresh your browser. You should now see your custom page instead of the default Apache page.
Step 9: Create a Virtual Host
If you plan to host your own domain, create a separate virtual host instead of using the default website.
Create a directory for your website.
sudo mkdir -p /var/www/example.com
Set the correct ownership.
sudo chown -R $USER:$USER /var/www/example.com
Create a sample web page.
nano /var/www/example.com/index.html
Example content:
<!DOCTYPE html>
<html>
<head>
<title>Example Website</title>
</head>
<body>
<h1>Welcome to example.com</h1>
</body>
</html>
Now create the Apache configuration file.
sudo nano /etc/apache2/sites-available/example.com.conf
Add the following configuration.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>
Enable the new site.
sudo a2ensite example.com.conf
Disable the default Apache site.
sudo a2dissite 000-default.conf
Check the Apache configuration for errors.
sudo apachectl configtest
If you see:
Syntax OK
Reload Apache.
sudo systemctl reload apache2
Your new virtual host is now ready. Point your domain's DNS record to your server's IP address, and Apache will serve your website.
Useful Apache Commands
Restart Apache
sudo systemctl restart apache2
Reload configuration without disconnecting users
sudo systemctl reload apache2
Stop Apache
sudo systemctl stop apache2
Start Apache
sudo systemctl start apache2
View Apache logs
sudo tail -f /var/log/apache2/error.log
Apache Configuration Files
The main Apache configuration files are located in:
/etc/apache2/
Some important directories include:
/etc/apache2/apache2.conf
/etc/apache2/sites-available/
/etc/apache2/sites-enabled/
/etc/apache2/mods-available/
/etc/apache2/mods-enabled/
These directories make it easy to manage multiple websites and enable or disable Apache modules.
Conclusion
We have seen how to install Apache on Ubuntu 26.04, verified that the service is running, configured the firewall, created your first website, and set up a virtual host for hosting your own domain. From here, you can install PHP, enable HTTPS with Let's Encrypt, or host multiple websites on the same server as your projects grow.

