Nginx 系列 - 用 GoAccess 实现可视化并实时监控 access 日志

栏目: 服务器 · Nginx · 发布时间: 6年前

内容简介:本例使用源码安装,在并重新加载配置文件:

一、安装使用

1. 安装 GoAccess

本例使用源码安装, ./configure 如果出错请看 问题说明 部分:

$ wget https://tar.goaccess.io/goaccess-1.3.tar.gz
$ tar -xzf goaccess-1.3.tar.gz
$ cd goaccess-1.3
$ ./configure --enable-utf8 --enable-geoip=legacy
$ make
# make install

2. 修改 Nginx 配置

nginx.conf 文件中新增以下配置:

location /report.html {
        alias /usr/local/nginx/html/report.html;
}

并重新加载配置文件:

$ /usr/local/nginx/sbin/nginx -s reload

3. 启动 GoAccess

在 nginx 安装目录下,执行 goaccess 命令:

$ cd /usr/local/nginx
$ goaccess ./logs/access.log -o ./html/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d/%b/%Y' --log-format=COMBINED
WebSocket server ready to accept new client connections

4. 访问服务

在浏览器中打开 http://127.0.0.1/report.html ,如出现以下页面则安装配置成功:

Nginx 系列 - 用 GoAccess 实现可视化并实时监控 access 日志

二、问题说明

本处整理了安装 GoAccess 执行 configure 命令报错和解决办法。

1. 如出现以下报错则需安装 GeoIP:

configure: error: 
    *** Missing development files for the GeoIP library

2. 如出现以下报错则需安装 NCurses:

checking for mvaddwstr in -lncursesw... no
configure: error: *** Missing development libraries for ncursesw

3. 解决办法

官方已经给出了各个平台对应依赖包的名字, 传送至官网 ,只需使用包管理 工具 安装即可,如下图:

Nginx 系列 - 用 GoAccess 实现可视化并实时监控 access 日志

如以上两个报错在 centos 下只需安装 geoip-devel 和 ncurses-devel 即可:

$ yum install geoip-devel ncurses-devel

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Compilers

Compilers

Alfred V. Aho、Monica S. Lam、Ravi Sethi、Jeffrey D. Ullman / Addison Wesley / 2006-9-10 / USD 186.80

This book provides the foundation for understanding the theory and pracitce of compilers. Revised and updated, it reflects the current state of compilation. Every chapter has been completely revised ......一起来看看 《Compilers》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

html转js在线工具
html转js在线工具

html转js在线工具