Setting up GoAccess involves installing the tool, configuring it to read your web server logs, and then running it to analyze the data. Here’s a step-by-step guide for installation and configuration:
On Ubuntu/Debian:
Update your package list:
sudo apt update
Install GoAccess:
sudo apt install goaccess
On CentOS/RHEL:
Enable the EPEL repository:
sudo yum install epel-release
Install GoAccess:
sudo yum install goaccess
From Source (for any distribution):
Install dependencies:
sudo apt install build-essential libgeoip-dev libglib2.0-dev
or
sudo yum install gcc-c++ GeoIP-devel glibc-devel
Download the latest GoAccess source from GoAccess GitHub releases.
Extract and install:
tar -xvzf goaccess-*.*.*.tar.gz
cd goaccess-*.*.*
./configure --with-geoip
make
sudo make install
Locate Your Log Files: Determine where your web server logs are stored (common locations are /var/log/apache2/access.log for Apache and /var/log/nginx/access.log for Nginx).
Run GoAccess: Use the command below to start analyzing logs. Replace /path/to/access.log with your actual log file path.
goaccess /path/to/access.log --log-format=COMBINED -a -o report.html
--log-format=COMBINED specifies the log format (adjust if necessary).-a enables the real-time mode.-o report.html generates an HTML report file.View the Report: Open the generated report.html file in a web browser to view your analysis.
Set Up Real-Time HTML Dashboard:
If you want to serve a real-time dashboard, you can use:
goaccess /path/to/access.log --log-format=COMBINED --real-time-html -o index.html
Then serve the index.html using a simple web server.
Use with a Web Server:
If you’re using a web server, you can serve the HTML report by copying it to your web server’s document root.
To regularly update your reports, consider using a cron job to run GoAccess at specified intervals.
Here’s an example cron job to run GoAccess every hour:
0 * * * * /usr/bin/goaccess /path/to/access.log --log-format=COMBINED -o /path/to/report.html