There is a new version of this tutorial available for Ubuntu 20.04 (Focal Fossa).

Install GoAccess Apache Log Analyzer Tool on Ubuntu 16.04

GoAccess is a free, open source and real time web server log analyzer tool that can be used to analyze and view web server logs. GoAccess is based on command line and also produces HTML reports that can be viewed through a web browser. It has several features including, General Statistics, bandwidth, Different Color Schemes, Top Visitors, Referring Sites & URLs, Operating Systems, Browsers, Metrics per Virtual Host and much more.

In this tutorial, we will learn how to install GoAccess in Ubuntu 16.04 server.

Requirements

  • A server running Ubuntu 16.04.
  • A non-root user with sudo privileges.

Getting Started

Before starting, it is recommended to update your system with the latest version. You can do this by running the following command:

sudo apt-get update -y
sudo apt-get upgrade -y

Once your system is updated, restart the system to apply all the updates.

Install Required Dependencies

GoAccess is written in the C programming language, so you will need to install some dependencies required by GoAccess. You can install all of them with the following command:

sudo apt-get -y install libncursesw5-dev gcc make libgeoip-dev libtokyocabinet-dev build-essential -y

Once all the dependencies are installed, you can proceed to the next step.

Install Apache Web Server

GoAccess is a web server log analyzer tool, so you will need to install Apache to your system. You can install it with the following command:

sudo apt-get install apache2 -y

Once the Apache is installed, start the apache service and enable it to start on boot time:

sudo systemctl start apache2
sudo systemctl enable apache2

Install GoAccess

You can install GoAccess using either from GoAccess source or from Ubuntu repository.

Install GoAccess from Source

First, you will need to download the latest version of the GoAccess from their official website with the following command:

wget http://tar.goaccess.io/goaccess-1.2.tar.gz

Next, extract the downloaded file with the following command:

tar -xzvf goaccess-1.2.tar.gz

Next, change the directory to the goaccess-1.2 and compile GoAccess by running the following command:

cd goaccess-1.2
sudo ./configure --enable-utf8 --enable-geoip=legacy
sudo make
sudo make install

Install GoAccess from Repository

First, you will need to add the GoAccess repository to the APT. You can do this with the following command:

echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -

Next, update the repository using the following command:

sudo apt-get update -y

Finally, install GoAccess by running the following command:

sudo apt-get install goaccess -y

Use GoAccess

GoAccess is now installed, it's time to test it with Apache web server.

First, open access your Apache web server using the URL http://your-server-ip. After accessing the Web server, Apache will add some log entries in the default access_log file.

Now, you can analyze the Apache web server log from a terminal using the following command:

sudo goaccess /var/log/apache2/access.log --log-format=COMBINED

You should see the Apache web server log report in the following image:

Apache GoAccess Log Analyzer

You can also generate an HTML report with the following command:

sudo goaccess /var/log/apache2/access.log --log-format=COMBINED -a -o /var/www/html/report.html

Once the report is generated, open your web browser and type the URL http://your-server-ip/report.html. You should see the report generated by GoAccess in the following image:

GoAccess HTML Report

Static report

Visitor Hostname and IP report

Browser report

Referring sites report

Congratulations! you have successfully installed GoAccess in Ubuntu 16.04 server. You can now easily analyze Apache web server log from a web interface and CLI.

Share this page:

1 Comment(s)