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 follow these steps:

  1. Install GoAccess:
sudo apt-get update
sudo apt-get install goaccess
  1. Install Nginx:
sudo apt-get update
sudo apt-get install nginx
  1. Configure Nginx to log access data:

Edit Nginx’s nginx.conf file and add the following log format to the http block:

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';

Then, in each server block, set the access_log directive to use the new log format:

access_log /var/log/nginx/access.log main;
  1. Generate the HTML report:
sudo goaccess /var/log/nginx/access.log -a > report.html
  1. Serve the HTML report with Nginx:

Create a new Nginx server block to serve the HTML report:

server {
listen 80;
root /var/www/html;
index report.html;
server_name example.com;

location / {
try_files $uri $uri/ /report.html;
}
}

Restart Nginx:

sudo service nginx restart
  1. Access the report:

Open a web browser and navigate to the server’s IP address or hostname to access the report.

Note: These are general steps to install and set up GoAccess with Nginx. Depending on your specific requirements and setup, you may need to make adjustments to the configuration files and commands used.

Leave a Comment