Web hostingWritten by GLWS8 min readUbuntu 24.04 LTS / AlmaLinux 9
Commands run on your server unless a section says otherwise. Replace example usernames, addresses and paths with your own values. Keep a working session open when changing remote access.

Use a suitable test server

Follow this guide on a fresh server or one you control that does not already host a website. You need an account with sudo privileges and working package repositories. Check for an existing listener on TCP port 80 before installing anything. If another service already owns the port, investigate that service first.

Ubuntu 24.04 LTS calls the package and service apache2. AlmaLinux 9 calls them httpd. Both installations can serve a simple file from /var/www/html. Choose the command block for your distribution; do not run both.

Check for an existing web service
sudo ss -lntp 'sport = :80'

Install and start Apache

Refresh Ubuntu's package index before installing. On AlmaLinux, DNF resolves the requested packages through its configured repositories. Installing curl gives you a convenient command-line HTTP test. Package installation may start the Ubuntu service automatically; the enable command also ensures it starts on subsequent boots.

Validate the supplied Apache configuration and confirm that the service is active. A syntax check reports configuration problems, while the service state establishes whether the process actually started.

Ubuntu 24.04 LTS
sudo apt update
sudo apt install apache2 curl
sudo apache2ctl configtest
sudo systemctl enable --now apache2
systemctl is-active apache2
AlmaLinux 9
sudo dnf install httpd curl
sudo httpd -t
sudo systemctl enable --now httpd
systemctl is-active httpd

Publish a separate test page

Create a small HTML file without replacing the existing index page. The command below uses shell noclobber mode, so it fails if glws-check.html already exists. If that happens, choose a different filename and use that name in the later URL.

On AlmaLinux, restore the expected SELinux label after creating the file. Keep SELinux enabled. Files under the standard web directory should use the policy's web-content context; moving content from another directory can carry an unsuitable label.

Create the test file on either distribution
sudo sh -c 'set -C; printf "%s\n" "<!doctype html><title>Apache test</title><h1>Apache is ready</h1>" > /var/www/html/glws-check.html'
sudo chmod 644 /var/www/html/glws-check.html
AlmaLinux 9: check the web-content label
sudo restorecon -v /var/www/html/glws-check.html

Verify locally, then externally

Request the test file using the loopback address. You should receive HTTP 200 and the HTML you created. Next, visit the same path using the server's public address from another device. A successful local request with a failed external request points toward routing or firewall access rather than the page itself.

If a firewall is already active, permit TCP 80 in its correct zone or rule set while retaining all existing access rules, including your actual SSH port. Provider firewalls may require a separate rule. Avoid enabling or resetting a firewall as part of this first web test.

Request the page locally
curl --fail --include http://127.0.0.1/glws-check.html
RECORDED LAB OUTPUT · Ubuntu 24.04 LTS
HTTP/1.1 200 OK
Server: Apache/2.4.58 (Ubuntu)
Content-Type: text/html
<!doctype html><title>Apache test</title><h1>Apache is ready</h1>
<!doctype html><title>Apache test</title><h1>Apache is ready</h1>
Apache test page verified
Recorded HTTP response from the practice Apache site. Date headers and package-install progress are omitted.

Inspect failures and plan the next step

For a failed start, inspect the relevant service journal. A 404 suggests a path or filename mismatch; a 403 suggests access restrictions, permissions, or policy. This establishes basic HTTP only. Before hosting user accounts or handling sensitive information, configure your domain and HTTPS, then test those separately.

Ubuntu service log
sudo journalctl -u apache2 -n 30 --no-pager
AlmaLinux service log
sudo journalctl -u httpd -n 30 --no-pager

Official documentation

These upstream references provide more detail on the commands and workflows in this guide.

Your first VPS: Next lesson: Connect your domain and enable HTTPS. View all nine lessons.