一、准备工作
nginx 安装的时候开启GeoIp模块
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_geoip_module && make && make install
开启utf8以及GeoIP,安装相应依赖包
utf8
yum install -y ncurses-devel
geoIp
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
#建立软链接
ln -s /usr/local/lib/libGeoIP.so* /lib64/
下载GeoIP数据库放入 /usr/local/share/GeoIP(比较老了,仅供参考)
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
二、安装GoAccess
wget http://tar.goaccess.io/goaccess-1.2.tar.gz
tar -xzvf goaccess-1.2.tar.gz
cd goaccess-1.2/
./configure --enable-utf8 --enable-geoip=legacy
make && make install
三、建立GoAccess监控日志
进入Nginx 的 access.log 目录
goaccess access.log -o ../html/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d/%b/%Y' --log-format=COMBINED