我的博客已迁移到xdoujiang.com请去那边和我交流

goaccess is a free (GPL) real-time web log analyzer and interactive viewer that runs
in a terminal in *nix systems.It provides fast and valuable HTTP statistics for system
administrators that require a visual server report on the fly.GoAccess parses the
specified web log file and outputs the data to the X terminal.
是一个用来统计 Apache Web 服务器的访问日志的工具,速度非常快,可即时生成统计报表.

一、Debian下安装goaccess
cat /etc/debian_version
6.0.10
apt-cache search goaccess
goaccess - log analyzer and interactive viewer for the Apache Webserver
apt-get -y install goaccess

二、Centos下安装goaccess
cat /etc/redhat-release
CentOS release 6.6 (Final)
yum list|grep goaccess
goaccess.x86_64                            0.8.5-1.el6                   epel
yum -y install goaccess
没有epel源的话需要安装
rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

三、参数说明

-b Enable total bandwidth consumption. To achieve faster parsing,
do not enable this flag.  This has been disabled by default.(流量统计)
-f input-file path to input log filename(日志文件名)
-s Enable/report HTTP status codes. To avoid overhead while parsing,
this has been disabled by default.(HTTP响应代码统计)
-e Exclude an IP from being count it under the HOST module.
This has been disabled by default.(指定IP地址统计,默认禁用)
-c Prompt log/date configuration window.(配置)
-a Enable a List of User-Agents by host.(用户代理统计)

四、功能说明
1、General Statistics(统计概况,流量消耗)
Number  of valid requests, number of invalid requests, time to analyze the data,
unique visitors, unique requested files, unique static files (css, ico, jpg,
js, swf, gif, png) unique HTTP referrers (URLs), unique 404s (not found),
size of the parsed log file, bandwidth consumption.
2、Unique visitors(访客排名)
HTTP requests having the same IP, same date and same agent will be considered a
unique visit. This includes crawlers.
3、Requested files(动态Web请求)
Hit totals are based on total requests. This module will display hits, percent,
bandwidth [time served], [protocol] and [method].
4、Requested static files(静态web请求,如图片、样式表、脚本等)
Hit totals are based on total requests. Includes files such as: jpg, css, swf, js,
gif, png etc.
This module will display hits,percent,bandwidth,[time served],[protocol] and [method].
5、404 or Not Found(404 错误)
Hit totals are based on total requests. This module will display hits, percent,
bandwidth, [time served], [protocol] and [method].
6、Operating Systems(操作系统)
Hit totals are based on unique visitors. This module will display hits and percent.
The expanded module shows all available versions of the parent node.
7、Browsers(浏览器和搜索引擎)
Hit totals are based on unique visitors. This module will display hits and percent.
The expanded module shows all available versions of the parent node.
8、HTTP Status Codes(HTTP 响应代码)
The values of the numeric status code to HTTP requests.
Hit totals are based on total requests. This module will display hits and percent.
9、Keyphrases(键盘布局)
This  module  will report keyphrases used on Google search, Google cache,
and Google translate. Hit totals are based on total requests. This module will dis-
play hits and percent.

五、官网
http://www.goaccess.io/

六、这里是在debian5.0.1上编译安装goaccess
1、下载
wget http://tar.goaccess.io/goaccess-0.9.tar.gz
或axel -n 5 http://tar.goaccess.io/goaccess-0.9.tar.gz
2、解压
tar -xzvf goaccess-0.9.tar.gz
3、configure
cd goaccess-0.9/
./configure --prefix=/opt/goaccess
4、编译并安装
make && make install
5、直接使用命令
cd /opt/goaccess/bin/
cp goaccess /usr/local/sbin/
PS:我这边将goaccess安装在/opt/goaccess目录下了。

七、命令行下如何使用

goaccess -f /var/log/apache2/aaa.access.log(当然其他nginx日志也可以的)
这个时候会弹出配置窗口:

goaccess安装和使用(命令行、网页等)_第1张图片

我这边选NCSA Combined Log Format
之后按enter就可以了
因为每次打开都会弹出这个配置窗口,可以修改以下配置文件
cat /opt/goaccess/etc/goaccess.conf |egrep -v "^#|^$"
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
再次执行的时候就不会弹出配置窗口了
也可以通过分析指定某1天的日志
grep '17/Apr/2015' aaa_access.log|goaccess

八、网页形式展示
未完待续