How to Install and Configure a Web Server in Ubuntu (Apache)


This guide covers web server Ubuntu step by step, with every setting in the order you will use it. Apache is the world’s most-used web server, and installing it on Ubuntu is famously a two-minute job. This guide goes from a bare Ubuntu Server to a working site, and explains the pieces so it works as a proper lab exercise, not just a copy-paste.

web server Ubuntu in a home lab

UBUNTU LINUXWEB SERVER UBUNTUENTERPRISE LABtimer 45 MIN LAB
NH
Nurul Huda AUTHORInfrastructure & Cloud Architect · Verified 2026

print Print Lab

● VALID ON THE CONFIG BELOW

dns LAB TOPOLOGY & PREREQUISITES

# example values used while writing and testing this guide

LAB VM

HypervisorVMware / ESXi
vCPU2
RAM2-4 GB
Disk40 GB

UBUNTU BUILD

Version24.04 LTS
Accesssudo user
IPstatic or DHCP
SSHenabled in lab

VALIDATION

Statussystemctl
Firewallufw lab rules
Snapshotbefore changes

01constructionWeb server Ubuntu: Step 1: Install Apache

Update packages and install the package:

sudo apt update && sudo apt install apache2 -y

Ubuntu’s installation enables and starts the service automatically. Check it: systemctl status apache2.

02downloadStep 2: Open the Firewall

If UFW is active, allow web traffic: sudo ufw allow 'Apache' (this opens port 80). From another machine, browse to the server’s IP — you should see Ubuntu’s default Apache2 Ubuntu Default Page. In short, web server Ubuntu works best when you follow the order above and verify each step.

03usbStep 3: Serve Your Own Content

The document root is /var/www/html. Replace the default page: sudo nano /var/www/html/index.html, write some HTML, reload the browser and you have a live site. That single page is enough to test the whole pipeline; for a real site you drop your files into this folder.

04terminalStep 4: Virtual Hosts (Multiple Sites)

Apache can serve many sites from one server. Copy the default configuration in /etc/apache2/sites-available, set a new ServerName (for example www.lab.local) and a new document root, then enable it and disable the default:

sudo a2ensite mysite && sudo a2dissite 000-default && sudo systemctl reload apache2

Point the name at your server in DNS or the hosts file, and each site resolves to its own content. The same model scales to production.

05settings_ethernetWhat Comes Next

Pair the web server with the Ubuntu database server to run applications like WordPress, and compare the experience with the IIS-based Windows Server web server or the fully managed S3 static hosting option on AWS. In short, web server Ubuntu works best when you follow the order above and verify each step.

Related Content

▶ UP NEXT IN THE UBUNTU TRACK

How to Install and Configure a Mail Server in Ubuntu (Postfix)

Finish this lab, then continue down the track. Each guide builds on the one before it.

rocket_launch Launch Next Lab