How to Install Apache on Ubuntu 20.04

How to Install Apache on Ubuntu 20.04

How to Install Apache on Ubuntu 20.04

We hope this post helped you to find out  How to Install Apache on Ubuntu 20.04

Apache is without doubt one of the hottest internet servers on the earth. It’s an open-source and cross-platform HTTP server that powers a big proportion of the Web’s web sites. Apache offers many highly effective options that may be prolonged by way of further modules.

This tutorial describes set up and handle the Apache webserver on Ubuntu 20.04.

Stipulations #

Earlier than beginning with the tutorial, be sure you are logged in as a person with sudo privileges.

Installing in Apache #

Apache is included within the default Ubuntu repositories.

The set up is fairly simple. On Ubuntu and Debian techniques, the Apache package deal and the service known as apache2.

Run the next instructions to replace the package deal index and set up Apache:

sudo apt update
sudo apt install apache2

When the set up course of, is full the Apache service will mechanically begin.

You’ll be able to confirm that Apache is working by typing:

sudo systemctl status apache2

The output ought to inform you that the service is working and enabled to start out on system boot:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-05-09 19:28:40 UTC; 36min ago

That’s it, you will have efficiently put in Apache in your Ubuntu 20.04 server, and you can begin utilizing it.

Opening HTTP and HTTPs Ports #

Apache listens on port 80 (HTTP) and 443 (HTTPS). You should open these ports in your firewall in order that the webserver is accessible from the Web.

Assuming you might be utilizing UFW, you are able to do that by enabling the ‘Apache Full’ profile which incorporates guidelines for each ports:

sudo ufw allow 'Apache Full'

Verify the change:

sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Apache Full                ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Apache Full (v6)           ALLOW       Anywhere (v6)

Verifying the Apache Installation #

To confirm that every part works accurately, open your browser, sort your server IP deal with http://YOUR_IP_OR_DOMAIN/, and you will note the default Ubuntu 20.04 Apache welcome web page as proven beneath:

The web page contains some fundamental details about Apache configuration recordsdata, helper scripts, and listing places.

Organising a Digital Host #

A Digital Host is an Apache configuration directive that means that you can run multiple web site on a single server. Sometimes a digital host describes one web site.

Apache ships with one digital host enabled by default. All domains that factors to the server IP deal with will match the default digital host. Should you’ll be internet hosting a single web site you possibly can add its content material in /var/www/html and edit modifying the digital host configuration discovered within the /and many others/apache2/sites-enabled/000-default.conf file.

Should you intend to host multiple web site, you’ll have to create a digital host configuration for every web site. On this part, we’ll arrange an internet site for a website referred to as “”. It’s best to substitute “” along with your area identify.

Step one is to create the doc root listing the place the web site recordsdata for the area identify might be saved and served in response to requests. Run the next command to create the listing:

sudo mkdir -p /var/www/

For testing purposes, create an index.html file inside the domain document root directory:


<!DOCTYPE html>
<html lang="en" dir="ltr">
    <meta charset="utf-8">
    <title>Welcome to</title>
    <h1>Success! home page!</h1>

Save and close the file when you are done.

To avoid permission issues, change the ownership of the domain document root directory to the apache user (www-data):

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

The following step is to create a digital host configuration for the “” area. The most effective observe is to retailer every vhost configuration in a separate file.

Apache vhosts recordsdata are saved in /etc/apache2/sites-available listing. The usual naming conference is to call the file in response to the area.

Open your textual content editor and create the next file:

<VirtualHost *:80>
    DocumentRoot /var/www/

    <Directory /var/www/>
        Options -Indexes +FollowSymLinks
        AllowOverride All

    ErrorLog ${APACHE_LOG_DIR}/
    CustomLog ${APACHE_LOG_DIR}/ combined

Apache does not read the configuration files found in the /etc/apache2/sites-available directory unless they are linked to the /etc/apache2/sites-enabled directory.

To activate the virtual host configuration, create a symlink using the a2ensite utility:

sudo a2ensite

Test the configuration for any syntax errors with:

sudo apachectl configtest

If there are no errors, you will see the following output:

Syntax OK

Restart the Apache service for the changes to take effect:

sudo systemctl restart apache2

Lastly, to confirm that every part is working as anticipated, open in your browser, and you will note one thing like this:

Conclusion #

We’ve proven you set up Apache on Ubuntu 20.04. You’re now prepared to start out deploying your functions and use Apache as an internet or proxy server.

We hope the How to Install Apache on Ubuntu 20.04 help you. If you have any query regarding How to Install Apache on Ubuntu 20.04 drop a comment below and we will get back to you at the earliest.

We hope this post helped you to find out  How to Install Apache on Ubuntu 20.04  . You may also want to see – How to Install Java on Ubuntu 20.04

Share via
Copy link
Powered by Social Snap