• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

强大Nginx日志分析工具——GoAccess【显哥出品,必为精品】

技术栈 lixian 4年前 (2020-08-04) 1657次浏览 2个评论 扫描二维码
文章目录[隐藏]

一、部署GoAccess

#上传代码包,也可以使用yum安装
[root@web01 ~]# ls
goaccess-1.4.tar.gz 

#解压
[root@web01 ~]# tar xf goaccess-1.4.tar.gz 
[root@web01 ~]# cd goaccess-1.4/

#安装依赖包
[root@web01 ~/goaccess-1.4]# yum install -y gcc  GeoIP-devel  ncurses-devel

#预编译
[root@web01 ~/goaccess-1.4]# ./configure --enable-utf8 --enable-geoip=legacy

#编译安装
[root@web01 ~/goaccess-1.4]# make && make install

#上传nginx日志文件,也可以在nginx日志文件copy一份
[root@web01 ~]# ls 
access.log  goaccess-1.4  goaccess-1.4.tar.gz 

#设置中文字符集
[root@web01 ~/goaccess-1.4]# export LANG=zh_CN.UTF-8

#基于终端的日志分析器
[root@web01 ~/goaccess-1.4]# goaccess -f /root/access.log 

强大Nginx日志分析工具——GoAccess【显哥出品,必为精品】

二、部署web页面GoAccess分析器

1.编写配置文件,将以下三行前面的#去掉

[root@web01 ~]# vim /usr/local/etc/goaccess/goaccess.conf
[root@web01 ~]# grep -Ev '^$|^#' /usr/local/etc/goaccess/goaccess.conf
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

2.编写nginx配置文件

[root@web01 ~]# cat /etc/nginx/conf.d/goaccess.conf
server {
    listen 80;
    server_name www.goaccess.com;
    location / {
        root  /code/log;
        index index.html index.htm;
    }
}

#创建站点目录
[root@web01 ~]# mkdir -p /code/log
#重启nginx
[root@web01 ~]# systemctl  restart nginx

3.执行命令 -o 生成html文件到站点目录

[root@web01 ~]# goaccess  -f /root/access.log -o /code/log/index.html  -p /usr/local/etc/goaccess/goaccess.conf 
Parsing... [34,780] [34,780/s]

4.浏览器访问域名(别忘了域名解析)

强大Nginx日志分析工具——GoAccess【显哥出品,必为精品】


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:强大Nginx日志分析工具——GoAccess【显哥出品,必为精品】
喜欢 (0)

您必须 登录 才能发表评论!

(2)个小伙伴在吐槽
  1. I may need your help. I've been doing research on gate io recently, and I've tried a lot of different things. Later, I read your article, and I think your way of writing has given me some innovative ideas, thank you very much.
    gateio2023-05-26 01:22
  2. Your article helped me a lot, is there any more related content? Thanks!