Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

How to Install GoAccess on Ubuntu 16.04

Last Updated: Fri, Aug 4, 2017
Linux Guides Server Apps System Admin Ubuntu
Archived content

This article is outdated and may not work correctly for current operating systems or software.

GoAccess is an open source web log analyzer. You can use it for analysis of logs on a real-time basis in either the terminal or a web browser. It processes many types of web access logs. It allows you to generate reports in HTML, JSON, and CSV format.

In this tutorial, we will install the latest version of GoAccess on Ubuntu 16.04.

Prerequisites

  • A Vultr Ubuntu 16.04 server instance (64-bit).

  • A sudo user.

Step 1: Perform a system update

Before installing any packages on the Ubuntu server instance, it is recommended to update the system. Log in using the sudo user and run the following commands to update the system.

sudo apt-get update

sudo apt-get -y upgrade

Once the system has finished upgrading, proceed to the next step.

Step 2: Install dependencies

GoAccess is written in the C programming language. Hence, the only required dependency is the ncurses library and gcc. To install the ncurses and gcc, run:

sudo apt-get -y install libncursesw5-dev gcc make

Install the optional packages by typing:

sudo apt-get -y install libgeoip-dev libtokyocabinet-dev

Step 3: Install GoAccess

Download the GoAccess tarball by running:

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

You can find the latest version of GoAccess on the official download page.

Extract the tarball.

tar -xzvf goaccess-1.2.tar.gz

Configure and install the package.

cd goaccess-1.2

sudo ./configure --enable-utf8 --enable-geoip=legacy

sudo make

sudo make install

Create a soft link of goaccess in the /usr/bin directory by running:

sudo ln -s /usr/local/bin/goaccess /usr/bin/goaccess

GoAccess is now installed on your server.

Step 4: Using GoAccess

GoAccess is a web log analyzer. If you do not have a web server running, install the Apache web server.

sudo apt-get -y install apache2

Start and enable the web server to run at boot time.

sudo systemctl start apache2

sudo systemctl enable apache2

Allow the required HTTP port through the system firewall.

sudo firewall-cmd --add-service=http --permanent

sudo firewall-cmd --reload

Now you can access the web server using http://Vultr_Server_IP. Upon accessing the web page, Apache will add some log entries in the default access_log file. The path to the log file on Ubuntu 16.04 is /var/log/apache2/access.log.

To analyze the log using GoAccess from a terminal, type:

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

The program will show you the generated report after analyzing the log file. An example report looks like the one shown below.

Dashboard - Overall Analyzed Requests (29/Jun/2017 - 29/Jun/2017)                               [Active Panel: Visitors]



  Total Requests  16 Unique Visitors  6  Unique Files 1 Referrers 0

  Valid Requests  16 Init. Proc. Time 0s Static Files 1 Log Size  3.44 KiB

  Failed Requests 0  Excl. IP Hits    0  Unique 404   2 Bandwidth 40.91 KiB

  Log Source      /var/log/apache2/access.log



 > 1 - Unique visitors per day - Including spiders                                                            Total: 1/1



 Hits      h% Vis.      v%   Bandwidth Data

 ---- ------- ---- ------- ----------- ----

 16   100.00%    6 100.00%   40.91 KiB 29/Jun/2017 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||















   2 - Requested Files (URLs)                                                                                 Total: 1/1



 Hits      h% Vis.      v%   Bandwidth Mtd Proto    Data

 ---- ------- ---- ------- ----------- --- -------- ----

 6    100.00%    5 100.00%   20.62 KiB GET HTTP/1.1 /















   3 - Static Requests                                                                                        Total: 1/1



 Hits      h% Vis.      v%   Bandwidth Mtd Proto    Data

 ---- ------- ---- ------- ----------- --- -------- ----

 [?] Help [Enter] Exp. Panel  0 - Thu Jun 29 11:29:56 2017                                           [Q]uit GoAccess 1.2

To generate an HTML report, type:

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

Open your web browser and navigate to the URL http://Vultr_Server_IP/report.html using your favorite web browser. The browser will show you many types of statistics using interactive graphs.

Want to contribute?

You could earn up to $600 by adding new articles.