安装 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