How to Configure Apache Web Server on Ubuntu and Debian

Fumbani Banda Feb 15, 2024
  1. The Apache Webserver in Ubuntu and Debian
  2. Apache Installation in Ubuntu and Debian
  3. Start Apache Webserver in Ubuntu and Debian
  4. Access Web Server Through a Browser
  5. Check Apache Access Logs in Ubuntu and Debian
How to Configure Apache Web Server on Ubuntu and Debian

This tutorial shows installing the Apache webserver on Ubuntu and Debian, setting it up and accessing the access logs.

The Apache Webserver in Ubuntu and Debian

Apache HTTP Server is a free and open-source web server and very popular.

More than half of the active websites on the internet use the apache web server. It is developed and maintained by the Apache Software Foundation.

Apache Installation in Ubuntu and Debian

The installation and configuration of the Apache webserver using the root account on Kali Linux can be performed by anyone.

To install the Apache on Ubuntu or Debian, run the following command.

apt-get install apache2

We run the command to install the Apache webserver in the image below. However, the system says that the Apache web server is already installed.

Command Used to Install the Apache Webserver

Start Apache Webserver in Ubuntu and Debian

Once the Apache webserver has been installed, we can start the server by running the following command.

service apache2 start

This command starts the webserver up and running. We can use the command service apache2 status to check the server’s status.

In the image below, we start the Apache webserver running, and we use the service apache2 status command to check the status of the webserver. The image shows that the server is actively running.

server is active running

Access Web Server Through a Browser

We can now access the webserver through the browser.

Open the browser of your choice. We have used Firefox in this tutorial and typed the localhost IP address.

The notation should look like the following.

http://your_server_ip

In our case, we have typed http://127.0.0.1 and pressed Enter. This should take you to the Apache default page.

If you see the Apache default page, it means you have successfully installed the Apache webserver on your system.

The Apache Default Page

Check Apache Access Logs in Ubuntu and Debian

Once the Apache web server installation is complete, users can access the website hosted by the Apache webserver.

The Apache web server logs the requests users make to the webserver. These logs are found in /var/log/apache2.

In the image below, we use the ls command to list the contents of the /var/log/apache2 folder. The access logs to the website hosted by the Apache webserver are found in the file, access.log.

Apache Access Logs

We use the cat command as a pipe operator and the tail command to print out the last 5 lines of the access.log file.

The image below shows the IP address requested by the web server, the request, the browser was used, and the version used.

Ip Address Requested the Web Server

Fumbani Banda avatar Fumbani Banda avatar

Fumbani is a tech enthusiast. He enjoys writing on Linux and Python as well as contributing to open-source projects.

LinkedIn GitHub