Installation
Installing GoAccess is pretty easy. Just download, extract and compile it with:
- $ wget https://tar.goaccess.io/goaccess-1.3.tar.gz
- $ tar -xzvf goaccess-1.3.tar.gz
- $ cd goaccess-1.3/
- $ ./configure --enable-utf8 --enable-geoip=legacy
- $ make
- # make install
Note: The only dependency is ncurses.
Info: If outputting real-time HTML, ensure port 7890 is opened. See more details.
Configure Options
Multiple options can be used to configure GoAccess. For a complete up- to-date list of configure options, run ./configure --help
- --enable-debug Compile with debugging symbols and turn off compiler optimizations.
- --enable-utf8 Compile with wide character support. Ncursesw is required.
- --enable-geoip=<legacy|mmdb> Compile with GeoLocation support. MaxMind's GeoIP is required. legacy will utilize the original GeoIP databases. mmdb will utilize the enhanced GeoIP2 databases.
- --enable-tcb=<memhash|btree> Compile with Tokyo Cabinet storage support. memhash will utilize Tokyo Cabinet's in-memory hash database. btree will utilize Tokyo Cabinet's on-disk B+ Tree database.
- --disable-zlib Disable zlib compression on B+ Tree database.
- --disable-bzip Disable bzip2 compression on B+ Tree database.
- --with-getline Dynamically expands line buffer in order to parse full line requests instead of using a fixed size buffer of 4096.
- --with-openssl Compile GoAccess with OpenSSL support for its WebSocket server. Note: Support for libssl1.1 has been added upstream.
Distributions
It is easiest to install GoAccess on Linux using the preferred package manager of your Linux distribution. Please note that not all distributions will have the lastest version of GoAccess available
Debian/Ubuntu
Note: This may not always give you the latest stable version. To make sure that you're running the latest stable version of GoAccess see option below.
Official GoAccess' Debian/Ubuntu Repository
- $ echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
- $ wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -
- $ sudo apt-get update
- $ sudo apt-get install goaccess
Notes
For on-disk support (Trusty+ or Wheezy+), run: sudo apt-get install goaccess-tcb.
.deb packages in the official repo are available through https as well. You may need to install apt-transport-https.
二、校对nginx和goaccess日志格式
a、配置nginx.conf中log_format中的日志格式(改完记得重启nginx服务),如:
复制代码
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$connection $upstream_addr '
'$upstream_response_time $request_time';
b、使用nginx2goaccess.sh脚本将nginx日志格式格式化为goaccess能识别的日志格式,nginx2goaccess.sh脚本内容在 https://www.cnblogs.com/erbiao/p/9221543.html
1、保存下来
2、使用如下方式获取日志格式:
sh nginx2goaccess.sh '' #log_format为你nginx.conf中配置的日志格式
如:
3、会得到三个格式:
date-format %d/%b/%Y
log_format %h - %^ [%d:%t %^] "%r" %s %b "%R" "%u" "%^" %^ %^ %^ %T
三、生成统计页面。上面三行分别是时间、日期、日志格式,将三行输出保存到任意文件,然后就可以开始生成html可视化文件
html可视化文件的实时更新方法(未测试)
选项解释
- -f 指定nginx日志文件
- -p 指定日志格式文件
- -o 输出到指定html文件
- --real-time-html 实时刷新
- --ws-url 绑定一个域名
参考:https://www.cnblogs.com/erbiao/p/9221671.html
https://goaccess.io/download
https://goaccess.io/man
没有评论