How to Install Apache on Ubuntu

Apache is the most widely used web server software in the world. It is the backbone of the internet, serving everything from tiny personal blogs to massive corporate infrastructure. If you want to host a website on your Linux server, installing Apache is the foundational first step.

Because Apache is open-source and incredibly popular, Canonical has included it directly in the default software repositories. This makes the installation process remarkably simple. Here is how to install Apache on Ubuntu and verify it is working.

Step 1: Update the Package Index

Before installing any critical software, you must tell your server to fetch the latest list of available packages. This guarantees you will download the most recent, secure version of Apache.

  1. Connect to your Ubuntu server via SSH (or open the terminal if you are using a desktop GUI).
  2. Type the following command:
    sudo apt update
  3. Press Enter and wait for the process to finish.

Step 2: Install Apache2

In the Ubuntu ecosystem, the Apache package is specifically named apache2.

  1. Type the installation command:
    sudo apt install apache2
  2. Press Enter.
  3. The terminal will list the dependencies it needs to install and ask for confirmation. Type Y and press Enter.

Ubuntu will automatically download the binaries, unpack them, and configure the default web directory. Crucially, it also starts the Apache service automatically; you do not need to reboot the server.

Step 3: Configure the UFW Firewall

If you are running a secure server, you likely have the Uncomplicated Firewall (UFW) enabled. By default, UFW blocks all incoming web traffic. You must explicitly tell the firewall to allow HTTP and HTTPS requests to reach Apache.

During installation, Apache registered itself with UFW. You can see the available application profiles by typing:

sudo ufw app list

You should see “Apache”, “Apache Full”, and “Apache Secure” in the list. To allow standard, unencrypted web traffic on Port 80, type:

sudo ufw allow 'Apache'

If you plan to install an SSL certificate later (which you should), you should allow both Port 80 and Port 443 by typing:

sudo ufw allow 'Apache Full'

Step 4: Verify the Web Server is Running

To confirm that Apache is successfully serving web pages, you can check its system status:

sudo systemctl status apache2

You should see a green dot and the words “active (running).”

For the ultimate test, open a web browser on your personal computer and type your Ubuntu server’s IP address into the address bar (e.g., http://192.168.1.50). You should be instantly greeted by the default “Apache2 Ubuntu Default Page,” confirming your web server is alive and accessible to the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.