网站日志分析工具goaccess安装配置实战

安装 GeoIP-devel ncurses-devel GeoIP-update

yum install glib2 glib2-devel GeoIP-devel  ncurses-devel zlib zlib-devel
yum install gcc -y
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum -y install GeoIP-update

安装goaccess

wget https://tar.goaccess.io/goaccess-1.3.tar.gz
tar xzvf goaccess-1.3.tar.gz
cd goaccess-1.3/ ; ./configure --enable-geoip --enable-utf8 ; make && make install

使用goaccess

修改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"';

nginx配置

location /report.html {
            alias /home/zopen/nginx/html/report.html;    #指定个人配置的目录
        }

修改文件/usr/local/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 access.log -o ../html/report.html --real-time-html --time-format='%H:%M:%S'  --date-format='%d/%b/%Y' --log-format=COMBINED

实时分析日志

/usr/local/bin/goaccess /var/log/nginx/access.log -o /usr/share/nginx/html/go.html  --real-time-html &

问题

问题1

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

解决方法:

$ wget https://github.com/maxmind/geoip-api-c/releases/download/v1.6.11/GeoIP-1.6.11.tar.gz
$ tar -xzvf GeoIP-1.6.11.tar.gz
$ cd GeoIP-1.6.11
$ ./configure
$ make
 make install

问题2

configure: error: *** Missing development libraries for ncursesw

解决方法:

要使用–enable-utf8,你需要安装ncursesw,下面是安装命令:

yum install ncurses-devel 
赞(1) 打赏
特别声明:除特殊标注,本站文章均为原创,遵循CC BY-NC 3.0,转载请注明出处。三伏磨 » 网站日志分析工具goaccess安装配置实战

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏