安装支持组件yum install geoip-devel
$ wget http://tar.goaccess.io/goaccess-1.2.tar.gz
$ tar -xzvf goaccess-1.2.tar.gz
$ cd goaccess-1.2/
$ ./configure --enable-utf8 --enable-geoip=legacy
$ make
# make install
goaccess.conf后增加日志格式
time-format %T
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
To generate an HTML report, just run it against your web log file: (-a is optional)
# goaccess /var/log/apache2/access.log -a -o report.html
OR
# zcat -f /var/log/apache2/access.log* | goaccess -a -o report.html
Just generate a static report and place the output html file under your web server www public folder. You need to add a couple of additional real-time flags. The use of --real-time-html is required.
# goaccess access.log -o /usr/share/nginx/www/rt.goaccess.io/report.html --real-time-html
Upon opening the generated report in your browser, the report will try to establish a WebSocket connection to the host name (window.location.hostname) where the generated report is running from.
Also, it is worth pointing out that if we want to run GoAccess at lower priority, we can run it as:
# nice -n 19 goaccess access.log -a
and if you don't want to install it on your server, you can still run it from your local machine:
# ssh root@192.168.9.213 'zcat /data/wwwlogs/nginx.log-2017*' | goaccess -a -o /data/wwwroot/Goaccess/report2017.html