Atlantic.Net Blog

How to Install Apache on Ubuntu 20.04

Atlantic.Net NOC
by Atlantic.Net (64 posts) under VPS Hosting
Verified and Tested 03/10/21


This how-to will help you with your install and configuration of Apache on your Ubuntu 20.04 server. Apache is a web server that is very popular in Linux systems and over the Internet. It is used by many Web Hosting companies worldwide because of its popularity and efficiency in hosting sites over the World Wide Web.


You need a Ubuntu 20.04 server that is configured with a static IP address. If you do not have a server already, you can spin up a secure virtual private server in under 30 seconds.

Install Apache on Ubuntu 20.04

The first step is to install Apache with the following command:

sudo apt-get install apache2

Start Apache with the following command:

service apache2 start

Verify if all is working by typing http://YOUR.IP.ADD.RESS
Your IP could be retrieved from the server with following command:

ifconfig eth0 | grep inet | awk '{ print $2 }'
This image is the default web page when installing Apache on Ubuntu 20.04

This image is the default web page when installing Apache on Ubuntu 20.04

Configure Apache (Single Host)

We will now configure Apache by opening the main configuration file and edit ServerName and  ServerAdmin lines accordingly.

nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.

        ServerAdmin [email protected]
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Save the file and restart the Apache HTTP service, so the changes take effect.

service apache2 restart

Now you can create/upload your web content to the HTML directory of Apache.(Remember to replace the existing index.html file with your index.html which is your home page)

nano /var/www/html/index.html


Configure Apache (Multi-Host)

If you would like to host multiple websites, proceed by opening the main configuration file, copy the existing Virtual Host entry and paste it underneath it. Then edit the ServerName, ServerAdmin, and  DocumentRoot lines accordingly.

nano /etc/apache2/sites-available/000-default.conf

Alternatively you can just copy the following entries and edit accordingly:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/site1
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/site2
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

We must now make directories for the sites that were just configured, site1 and site2.

mkdir /var/www/site1
mkdir /var/www/site2

Now you may begin creating/uploading your web content in the sites directory of Apache.

nano /var/www/site1/index.html
nano /var/www/site2/index.html

What Next?

With that, you now have a server installed and configured with Apache. You may now continue building your website. Thank you for following along and feel free to check back with us for further updates, take a look at other Ubuntu related posts in our blog or learn more about our award-winning VPS hosting solutions.

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Set Up Kubernetes Cluster Using Minikube on Arch Linux
How to Install Jenkins on Arch Linux
Which Compliance Standards Require an IPS?
Install Netdata Monitoring Tool on Arch Linux
How to Install Vue.js on Arch Linux

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Garland, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4


London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom