Install and Configure Apache On Ubuntu 18.04 | 16.04 - Step by Step Process.

The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.

Apache allows website developers to serve their content over the web.

It serves as a delivery man by delivering files requested by users when they enter a domain name in their browser's address bar.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Apache queries on Ubuntu Linux Servers.

In this context, we shall look into how to install Apache2 HTTP server on Ubuntu 18.04 | 16.04.

How to install and Configure Apache2 on Ubuntu ?

To get started installing and configuring Apache2, continue with the steps below.

1. Install Apache2 server

It only takes a single command line to install Apache2. The difficult portion is configuring it to run properly.

To install Apache2 on Ubuntu, run the commands below.

$ sudo apt-get -y install apache2

2. Manage Apache2 server

After you install Apache2, it might be better to know simple commands to manage the server. 

The lines below show you how to stop, start, restart and reload Apache2 server.

— Stops the server:  

$ sudo systemctl stop apache2

— Starts the server:  

$ sudo systemctl start apache2

— Restarts the server:  

$ sudo systemctl restart apache2

—  Reload config changes no stops:  

$ sudo systemctl reload apache2

3. Configure Apache2 Server

When Apache2 is installed on Ubuntu, by default its root directory is created at this location: /var/www/html

Any file you save in there that is probably configured with HTML standard ending in .html, apache2 will be able to serve to web clients. 

It is the root directory for the server.

This is the location the server looks to serve .html/htm documents.

The majority of Apache2 configuration files are stored in /etc/apache2 directory. 

In this directory is where you'll fine server configuration settings, root directory controls and many of the different files that control Apache2 servers.

Two important locations that you'll spend most of your time are /etc/apache2/sites-available and /etc/apache2/sites-enabled.

The sites-available directory contains all the available sites. 

This is the location you create new sites in.

Also, sites-enabled directory contains all sites that are enabled. 

By default, sites are not enabled until you run a commands to enable them.

The first default available site that's also enabled is /etc/apache2/sites-available/000-default.conf.

This file contains the basic Apache2 test settings configurations. 

You can keep the default site and continue to configure it or copy the default site into something new and work from there. 

Make sure to enable the new site though.

4.  Enable and Disable Apache2 Sites

After you configure your sites, you must enable them before they become operational. 

The commands below show you how to enable and disable Apache2 sites.

— Enable site example.com

$ sudo a2ensite example.com

— Disable site example.com  

$ sudo a2dissite example.com

Other modules can be enabled and disabled as well. 

Modules are codes/programs that are used to enhance Apache2 functionality or enable new features.

— Enable a module:  

$ sudo a2enmod  module_name

— Disable a module:  

$ sudo a2dismod  module_name

This is the basic to Apache2

Because Apache2 is installed and the default site enabled, if you open your web browser and browse to the computer name or IP address, you'll see Apache2 default test page.

[Need help in configuring Apache Web Server on your Linux Server? We can help you. ]


This article covers how to install an Apache web server on your Ubuntu 20.04 server.

Apache or Apache HTTP server is a free and open source web server, developed and maintained by the Apache Software Foundation.

Apache allows website developers to serve their content over the web. It serves as a delivery man by delivering files requested by users when they enter a domain name in their browser's address bar.

To Install Apache 2 on Ubuntu Linux:

1. You can download the latest version of a software by first updating the local package index of Ubuntu repositories. Open the Terminal and enter the following command in order to do so:

$ sudo apt update

2. Next, enter the following command as sudo in order to install Apache2 and its required dependencies:

$ sudo apt install apache2

You may be prompted with a y/n option to continue installation. Please enter Y, after which the installation procedure will begin.

3. When the installation is complete, you can check the version number and thus verify that Apache2 is indeed installed on your system by entering the following command:

$ apache2 -version

Apache Server Logs Location:

1. /var/log/apache2/access.log: By default, every request to your web server is recorded in this log file unless Apache is configured to do otherwise.

2. /var/log/apache2/error.log: By default, all errors are recorded in this file.

The LogLevel directive in the Apache configuration specifies how much detail the error logs will contain.