How to install GoAccess web log analyzer with Nginx on Linux or Unix

How to install GoAccess web log analyzer with Nginx on Linux or Unix

To install GoAccess web log analyzer with Nginx on Linux or Unix, you can use the following steps:

  1. Install GoAccess:
    Follow the instructions at https://goaccess.io/download to install GoAccess on your system. This installs the goaccess command-line utility.

  2. Configure Nginx to generate log files in the format required by GoAccess:
    Add the following lines to the http block in your Nginx configuration file (usually located at /etc/nginx/nginx.conf):

log_format goaccess '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
access_log /var/log/nginx/access.log goaccess;
Source:‮ww‬w.lautturi.com

These lines define a log format that is compatible with GoAccess and specify that Nginx should use this log format when writing log files.

  1. Restart Nginx to apply the changes:
    sudo systemctl restart nginx

  2. Analyze the log files with GoAccess:
    goaccess /var/log/nginx/access.log
    This runs GoAccess on the Nginx log files and displays the results in a terminal window.

GoAccess is a real-time web log analyzer that provides detailed statistics about web traffic and performance. It can be used with Nginx (or other web servers) to analyze log files and generate reports about visits, visitors, and other aspects of web traffic.

Note: These steps assume that you are using a system that uses the systemctl command to manage services. If you are using a different init system or a different Linux distribution, you may need to use different commands to restart Nginx.

Created Time:2017-10-16 14:38:47  Author:lautturi