goaccess 分析 nginx日志

原文地址
https://blog.51cto.com/13444271/2167514

安装

yum install glib2 glib2-devel GeoIP-devel  ncurses-devel zlib zlib-develyum install gcc -y
yum -y install GeoIP-update
yum install goaccess

#修改/etc/nginx/nginx.conf文件的日志存储格式
log_format  main  '$remote_addr - $remote_user [$time_local] requesthost:"$http_host"; "$request" requesttime:"$request_time"; '
        '$status $body_bytes_sent "$http_referer" - $request_body'                      
        '"$http_user_agent" "$http_x_forwarded_for"';

        
#修改文件/etc/goaccess.conf改成goaccess格式标准对应为
time-format %T
date-format %d/%b/%Y
log-format %h - %^ [%d:%t %^] requesthost:"%v"; "%r" requesttime:"%T"; %s %b "%R" - %^"%u"

#测试生成页面
goaccess -f /var/log/nginx/access.log -c -a>/usr/share/nginx/html/go.html

控制台

goaccess /data/wwwlogs/access_all.log

页面展示

goaccess /data/wwwlogs/access_all.log -c -a>/data/wwwroot/test.iguojin.com/log/index.html

此处评论已关闭