How to Install GoAccess Web Analytics on Debian

GoAccess is a light-weight free open source log analyzer. Matomo and other self-hosted website analytics applications use PHP and a SQL database to manage web analytics data. Other applications including Google Analytics and Mixpanel store the data externally.

GoAccess uses your pre-existing server logs to provide web analytics data you can easily manipulate within your web browser, spreadsheet application, or command-line interface.

There are a few advantages to this:

  • Faster, easier configuration with automated CLI tasks
  • More security on cloud servers since system administrators (sysadmins) don’t need to install PHP and MySQL
  • Another option for users on cPanel servers wanting to know how to check server error logs outside of cPanel with a sleek GUI

Below we cover:

Experienced sysadmins may not want cPanel. You may only need secure, Debian Cloud Server Hosting.

Install GoAccess

  1. Log into SSH
  2. Create a file for the official GoAccess repo:
    echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
  3. Download the GoAccess GPG key to ensure you install a verified GoAccess application:
    wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/goaccess.gpg add -
  4. Update your system repositories:
    sudo apt-get update
  5. Install GoAccess:
    sudo apt-get install goaccess 

Configure GoAccess for Apache

There are multiple ways to configure GoAccess reporting for your server environment. If the time format is configured wrong, or not at all, you’ll likely receive the following error with GoAccess log parsing commands:

GoAccess - version 1.4 - May 18 2020 01:28:37
Config file: /etc/goaccess/goaccess.conf

Fatal error has occurred
Error occurred at: src/parser.c - parse_log - 2777
No time format was found on your conf file.

The easiest way to quickly get started with GoAccess is use --log-format=COMBINED:

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

Below we’ll cover the manual method for configuring GoAccess permanently so that you can use less options when producing GoAccess reports.

  1. Edit your GoAccess configuration file:
    nano /etc/goaccess/goaccess.conf
  2. Un-comment (meaning remove the # in the beginning of) line 13, under Apache/NGINX's log formats below:
    time-format %H:%M:%S

    To jump to line numbers with Nano, type Ctrl + Shift + _, then the line number, and Enter.

  3. Un-comment line 36, under Apache/NGINX's log formats below:
    date-format %d/%b/%Y
  4. Un-comment line 70, under Common Log Format (CLF):
    log-format %h %^[%d:%t %^] "%r" %s %b
  5. Un-comment line 330, under priority over -f from the command line:
    log-file /var/log/apache2/access.log
  6. Exit the file and save changes: Ctrl + X , Y, then Enter

Create a GoAccess Report

GoAccess allows you to create reports in multiple formats – terminal, HTML, CSV (for spreadsheets), and JSON (for APIs).

Create a GoAccess Report in the Terminal

  1. Specify a log file with the -c option:
    goaccess /var/log/apache2/access.log -c 
  2. Scroll down and select [ ] Common Log Format (CLF) with the space bar, then Enter
  3. Scroll through the different sections of results with the up and down arrows
GoAccess Terminal Requested Files panel

Create a HTML GoAccess Report for the Web Browser

If you haven’t configured your GoAccess configuration file, you can use the following commands to create an HTML report:

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

If you’ve configured your GoAccess configuration file, you can omit the log format:

goaccess /var/log/apache2/access.log -a -o /var/www/html/report.html

If you wish to use all access log files available, not just for the current day, you can use zcat to feed archived log files into your GoAccess log parse:

zcat -f /var/log/apache2/access.log.* | goaccess -o /var/www/html/report.html

Below is a completed HTML report example.

GoAccess Dashboard Visitors and Requests panels

The two buttons on the left serve two major functions:

  • Skip to different panels (log sections)
  • Change the report appearance – color theme, items (rows) shown at once in each section, and more

Learn how to do more with your logs in the online GoAccess manual.

J
Jacqueem Technical Writer

Technical writer focused on cybersecurity and musicianship.

More Articles by Jacqueem

Was this article helpful? Let us know!