[2 min installs] Apache on Ubuntu

Better Stack Team
Updated on August 30, 2022

Here is how to install Apache web server on Ubuntu 20.04 in under two minutes:

Step 1 - Install Apache

The first step is to update the package repository cache and install Apache.

sudo apt-get update
sudo apt install apache2 -y

apt update downloads the package lists from the repositories and updates them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs.

Step 2 - Start the web server

Make sure the webserver is running before moving to the third step.

sudo service apache2 start

Step 3 - Adjust the firewall

The next step is to adjust the firewall to allow web traffic. While installing apache, the installation program also created an application profile for the firewall. All you need to do is to enable it:

sudo ufw allow in "Apache Full"

That’s it

Everything is ready now. If you want to test the connection, simply type your server's IP address into the browser and you should see “Apache2 Ubuntu default page”. The following steps may be setting up a virtual host to allow you to host multiple applications on your web server and refer to them by domain instead of the IP.

Check Uptime, Ping, Ports, SSL and more.
Get Slack, SMS and phone incident alerts.
Easy on-call duty scheduling.
Create free status page on your domain.
Got an article suggestion? Let us know
Next article
[2 min installs] Docker on Ubuntu
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.