How to Install Apache Web Server on Ubuntu 20.04 Tutorial (Step by Step)

This article explains how to Install Apache Web Server on Ubuntu 20.04. I will introduce what Apache Web Server is and it’s main features and navigate to installation steps.

What is Apache Web Server?

Apache is a reliable web server software maintained and developed by the Apache Software Foundation. Its first version got released in 1995 with the aim to provide a secure server to users that helps sync HTTP services with the current HTTP standards. Today, most developers, hosting providers and website owners use Apache server because it is a free and open source web server compatible with every operating system and provides excellent performance.

Firstly, Apache HTTP Web Server is not any physical server but software that helps transfer files back and forth between clients and servers. Apache web server role is to create a link between the servers and web browsers (Google Chrome, Firefox, etc.) for delivering web content.

It is written in C language, easy to configure and stands one of the fastest software that helps establish a smooth and secure connection between two sources. Let’s say, for instance, if a visitor wants to open a page on the website, the web browser will immediately inform the server, and Apache will help deliver the requested files in response. Furthermore, its open source infrastructure is of great advantage to developers as they can view and customize the source code as per the need.

In addition, the software offers various modules for web security, caching, password authentication, and more. mod_domain, mod_mbox, mod_ftp, Sandbox, mod_pop3, mod_smtpd, are a few modules provided by the software. In order to configure them, you will require permission to use .htaccess. Server administrators can manage these additional functionalities and eliminate unwanted modules as per the need. Thus, turning Apache into more lightweight and efficient software. The best part about choosing Apache web server over other web servers is it can handle heavy traffic with minimal configurations.

Finally Apache server uses an HTTP protocol to accept requests from internet users and deliver the requested information as files and Web pages. You can run this software on various operating systems, including Windows, Linux, FreeBSD, Mac OS X, Novell Netware, Solaris, etc. LinkedIn, Facebook, Salesforce, Siemens, eBay, Cisco, IBM are a few high profile companies that use Apache Web Server.

Features of Apache Web Server

Apache web server is a good choice for enterprises looking forward to running a website on a stable platform. It is one of the oldest web servers and can handle heavy traffic. Check out some of the key features of the Apache webserver software.

  • Apache is free, open source software that is easy to view and customize.
  • Fast, secure and easy to configure webserver software.
  • Flexible module based structure.
  • Supports various programming languages, such as PHP, Python, etc.
  • Supports URL rewriting.
  • Supports HTTP/2 and FTP server connections.
  • Provides Auto indexing features.
  • The popular web server software is compatible with IPv6.
  • In built Perl, PHP, and Lua scripts.
  • Bandwidth throttling.
  • Easy to run on various operating systems such as Linux, OSX, Solaris, Windows, FreeBSD, etc.
  • Supports SSL certificate and CGL.
  • Custom logging and rotation.
  • Geolocation based on IP address.
  • Supports various CMS (WordPress and Joomla).
  • Active community support.

In the next section of this tutorial we will show you how to install the Apache web server on Ubuntu 20.04.

How to Install Apache Web Server on Ubuntu 20.04

Install Apache Web Server

By default, the Apache webserver is included in the Ubuntu default repository. You can install it by just running the following command:

					apt-get install apache2 -y

This will install the Apache webserver to your system and also starts the Apache service. By default, Apache listens on port 80. You can check it with the following command:

					ss -antpl | grep 80

You will get the following output:

					LISTEN   0         511                       *:80                     *:*       

Now, open your web browser and access the Apache test page using the URL http://your-server-ip. You should see the Apache test page in the following screen:

Manage Apache Service

At this point, the Apache web server is up and running. You can manage the Apache service using the systemctl command line utility.

To stop the Apache service, run the following command:

					systemctl stop apache2

To restart the Apache service, run the following command:

					systemctl restart apache2

If you want to enable the Apache service to start at system reboot, run the following command:

					systemctl enable apache2

To verify the status of the Apache service, run the following command:

					systemctl status apache2

You will get the following output:

					● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-01-29 14:57:04 UTC; 8s ago
    Process: 17903 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 17907 (apache2)
      Tasks: 6 (limit: 2341)
     Memory: 19.9M
        CPU: 104ms
     CGroup: /system.slice/apache2.service
             ├─17907 /usr/sbin/apache2 -k start
             ├─17908 /usr/sbin/apache2 -k start
             ├─17909 /usr/sbin/apache2 -k start
             ├─17910 /usr/sbin/apache2 -k start
             ├─17911 /usr/sbin/apache2 -k start
             └─17912 /usr/sbin/apache2 -k start

Jan 29 14:57:04 ubuntu2004 systemd[1]: Starting The Apache HTTP Server...


Setup Apache Virtual Hosts

Next step of how to Install Apache Web Server on Ubuntu 20.04 is virtual hosting. Apache provides virtual hosting feature that allow you to host multiple websites on a single server. In this section, we will host a new website using the domain name

Create a Website Directory

First, you will need to create a directory for your new website:

					mkdir /var/www/html/

Next, change the ownership of your website directory to www-data:

					chown -R www-data:www-data /var/www/html/

Following step is for you to set a proper permission to the website directory.

					chmod -R 755 /var/www/html/

Next step is for you to create an Index.html page inside your website directory:

					nano /var/www/html/

Add the following code:

        <title>Welcome to Apache Web Server!</title>
        <h2>Success!  The virtual host is working!</h2>
    <script>class RocketElementorAnimation{constructor(){this.deviceMode=document.createElement("span"),"elementor-device-mode",this.deviceMode.setAttribute("class","elementor-screen-only"),document.body.appendChild(this.deviceMode)}_detectAnimations(){let t=getComputedStyle(this.deviceMode,":after").content.replace(/"/g,"");this.animationSettingKeys=this._listAnimationSettingsKeys(t),document.querySelectorAll(".elementor-invisible[data-settings]").forEach(t=>{const e=t.getBoundingClientRect();if(e.bottom>=0&&<=window.innerHeight)try{this._animateElement(t)}catch(t){}})}_animateElement(t){const e=JSON.parse(t.dataset.settings),i=e._animation_delay||e.animation_delay||0,n=e[this.animationSettingKeys.find(t=>e[t])];if("none"===n)return void t.classList.remove("elementor-invisible");t.classList.remove(n),this.currentAnimation&&t.classList.remove(this.currentAnimation),this.currentAnimation=n;let s=setTimeout(()=>{t.classList.remove("elementor-invisible"),t.classList.add("animated",n),this._removeAnimationSettings(t,e)},i);window.addEventListener("rocket-startLoading",function(){clearTimeout(s)})}_listAnimationSettingsKeys(t="mobile"){const e=[""];switch(t){case"mobile":e.unshift("_mobile");case"tablet":e.unshift("_tablet");case"desktop":e.unshift("_desktop")}const i=[];return["animation","_animation"].forEach(t=>{e.forEach(e=>{i.push(t+e)})}),i}_removeAnimationSettings(t,e){this._listAnimationSettingsKeys().forEach(t=>delete e[t]),t.dataset.settings=JSON.stringify(e)}static run(){const t=new RocketElementorAnimation;requestAnimationFrame(t._detectAnimations.bind(t))}}document.addEventListener("DOMContentLoaded",;</script></body>


Save and close the file when you are finished.

Configure Apache to Serve the Web Directory

Next, you will need to create an Apache virtual host configuration file to serve the index.html file over the internet. You can create it with the following command:

					nano /etc/apache2/sites-available/example.conf

Add the following configuration:

					<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


Save and close the file then activate the Apache virtual host with the following command:

					a2ensite example.conf

Next you must restart the Apache service to apply the configuration changes:

					systemctl restart apache2

Verify Apache Virtual Host

At this point, the Apache web server is configured to serve the index.html page via domain. You can now test it using the URL in your web browser. You should see the following page:

Install Apache Web Server on Ubuntu 20.04 Conclusion

In the above guide, we explained how to install the Apache webserver on Ubuntu 20.04. We have also explained how to use virtual hosting to host a website on the internet. I hope this guide will help you to host multiple websites on a single server.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x