安装基础环境yum install -y ncurses-devel geoip-devel libmaxminddb-devel openssl-devel
解压编译安装tar xvf goaccess-1.9.1.tar.gz
cd goaccess-1.9.1
./configure --enable-utf8 --enable-geoip=mmdb
make && make install
测试
# goaccess
GoAccess - version 1.9.1 - Feb 6 2024 13:35:09
Config file: /usr/local/etc/goaccess/goaccess.conf
Fatal error has occurred
Error occurred at: src/goaccess.c - initializer - 1514
No input data was provided nor there's data to restore.
goaccess配置echo "time-format %H:%M:%S" >> /usr/local/etc/goaccess/goaccess.conf
echo "date-format %d/%b/%Y" >> /usr/local/etc/goaccess/goaccess.conf
echo 'log_format %h - ~h{,} [%d:%t %^] "%r" %s %b "%R" "%u" "%T" %^' >> /usr/local/etc/goaccess/goaccess.conf
nginx日志配置
log_format main '$remote_addr - $http_x_forwarded_for [$time_local] '
' "$request" $status $body_bytes_sent '
' "$http_referer" "$http_user_agent" '
' "$request_time" "$upstream_response_time"';
输出中文分析LANG="zh_CN.UTF-8" bash -c "goaccess log.log -o log.html"