How to Install GoAccess on CentOS 7
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 CentOS 7.
##Prerequisites
- A Vultr CentOS 7 server instance (64-bit).
- A sudo user.
##Step 1: Perform a system update
Before installing any packages on the CentOS 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 yum -y install epel-release
sudo yum -y update
sudo shutdown -r now
Once the system has finished rebooting, log in again as the sudo user and 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 yum -y install ncurses-devel gcc
Install the optional packages by typing:
sudo yum -y install geoip-devel tokyocabinet-devel
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 yum -y install httpd
Start and enable the web server to run at boot time.
sudo systemctl start httpd
sudo systemctl enable httpd
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 CentOS 7 is /var/log/httpd/access_log
.
To analyze the log using GoAccess from a terminal, type:
sudo goaccess /var/log/httpd/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 1 Unique Files 1 Referrers 0
Valid Requests 16 Init. Proc. Time 0s Static Files 4 Log Size 3.92 KiB
Failed Requests 0 Excl. IP Hits 0 Unique 404 6 Bandwidth 41.82 KiB
Log Source /var/log/httpd/access_log
> 1 - Unique visitors per day - Including spiders Total: 1/1
Hits h% Vis. v% Bandwidth Data
---- ------- ---- ------- ----------- ----
16 100.00% 1 100.00% 41.82 KiB 29/Jun/2017 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 - Requested Files (URLs) Total: 1/1
Hits h% Vis. v% Bandwidth Mtd Proto Data
---- ------- ---- ----- ----------- --- -------- ----
2 100.00% 0 0.00% 9.56 KiB GET HTTP/1.1 /
3 - Static Requests Total: 4/4
Hits h% Vis. v% Bandwidth Mtd Proto Data
---- ------ ---- ------ ----------- --- -------- ----
[?] Help [Enter] Exp. Panel 0 - Thu Jun 29 10:20:31 2017 [Q]uit GoAccess 1.2
To generate an HTML report, type:
sudo goaccess /var/log/httpd/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.