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 GoAccess on CentOS 7.


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:
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. 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. That’s all! Enjoy GreenCloudVPS services!        
On this page