Installing GoAccess on CentOS 7: A Real-Time Web Log Analyzer
GoAccess is a freely available web log analyzer. It enables you to examine access logs live either through the terminal or via a web browser. Supporting various web log formats, it can produce reports in formats such as HTML, JSON, and CSV.
This tutorial outlines the procedure to install the newest version of GoAccess on a CentOS 7 server.
Prerequisites
- A 64-bit CentOS 7 server instance
- An account with sudo privileges
Step 1: Update Your System
Before installing any software packages, it’s a good practice to update your CentOS server. Access your server using the sudo user credentials and run the commands below to update the system:
sudo yum -y install epel-release
sudo yum -y update
sudo shutdown -r now
After your server completes the reboot, log back in with the sudo user and continue with the installation.
Step 2: Install Required Packages
GoAccess is developed in the C language, so it requires the ncurses
library and gcc
compiler to function. To install these, use the following command:
sudo yum -y install ncurses-devel gcc
To include optional features, install additional packages using:
sudo yum -y install geoip-devel tokyocabinet-devel
Step 3: Install GoAccess
To begin the installation, download the GoAccess archive file using the command below:
wget http://tar.goaccess.io/goaccess-1.2.tar.gz
You can always get the most recent version from GoAccess’s official download page.
Once downloaded, extract the contents of the archive:
tar -xzvf goaccess-1.2.tar.gz
Navigate into the extracted directory, configure the build settings, and compile the software:
cd goaccess-1.2
sudo ./configure --enable-utf8 --enable-geoip=legacy
sudo make
sudo make install
After the installation is complete, create a symbolic link to make GoAccess accessible from anywhere in the terminal:
sudo ln -s /usr/local/bin/goaccess /usr/bin/goaccess
GoAccess has now been successfully installed on your CentOS 7 server.
Step 4: Using GoAccess for Web Log Analysis
GoAccess serves as a web log analyzer. If you haven’t already configured a web server, you can install Apache by executing the command below:
sudo yum -y install httpd
Enable and start the Apache service so it will launch automatically upon boot:
sudo systemctl start httpd
sudo systemctl enable httpd
Allow HTTP traffic through the firewall to ensure web access is available:
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
To examine the log file directly from the terminal using GoAccess, run:
sudo goaccess /var/log/httpd/access_log --log-format=COMBINED
After parsing the file, GoAccess will generate a live statistics report similar to the following:
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 create an interactive HTML report, execute the following command:
sudo goaccess /var/log/httpd/access_log --log-format=COMBINED -a -o /var/www/html/report.html
Conclusion
By following this guide, you’ve successfully installed and configured GoAccess on a CentOS 7 server. With this powerful tool, you can now analyze your web access logs in real-time, either via the command line or through a web-based report. Whether you’re looking to monitor visitors, request patterns, or bandwidth usage, GoAccess provides an efficient and interactive way to visualize your server’s activity. This helps in optimizing performance, identifying issues, and understanding user behavior more effectively.