1.材料准备
1.1 Nginx的main标准的访问日志,
其内容大致如下:
如图中log_format main 中所示即为配置的日志访问记录项的格式:
1.2 Goaccess程序包以及Geo IP位置归属资源包
可以通过weget安装,去官网下载安装,或者百度网盘链接
wget http://tar.goaccess.io/goaccess-1.1.tar.gz
链接:https://pan.baidu.com/s/1I602Z_0CYjpDGQtF3dk9Rg
提取码:cccc
Geo IP位置归属资源包也在网盘链接里面,使用的适合解压到合适位置即可
gunzip GeoLiteCity.dat.gz
1.3 环境配置
安装一些相关的依赖
yum install glib2 glib2-devel GeoIP-devel ncurses-devel
将相应的文件放到同一路径下
2 配置日志格式
首先进入goaccess 目录下
cd goaccess-1.1/
./configure --enable-geoip --enable-utf8 --with-openssl
make && make install
goaccess -f /nginxloganalysis/access.log -a
配置goaccess实现地理位置分析
goaccess -f /nginxloganalysis/access.log
--log-format="%h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\""
--date-format="%d/%b/%Y"
--time-format=%H:%M:%S -a
--geoip-database=/nginxloganalysis/GeoLiteCity.dat
/nginxloganalysis/nginx-log-`date +%F-%H-%M-%S`.html # 生成的html文件
3 结果展示
参考文章
https://www.cnblogs.com/marility/p/7280061.html
https://www.goaccess.cc/?mod=man