使用goaccess在浏览器上面实时查看nginx的日志。html
登陆CentOS服务器,使用yum安装goaccess:nginx
yum install goaccess 没有可用软件包 goaccess。
centos7的yum中没有goaccess,接下来只有手动编译安装了。vim
yum install ncurses-devel yum install geoip-devel yum install tokyocabinet-devel yum install openssl-devel
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
vim /var/nginx/conf/nginx.conf # 添加请求配置 location /report.html { alias /var/nginx/html/report.html; }
systemctl restart nginx.service
cd /var/nginx/logs goaccess budget.access.log -o ../html/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d%b%Y' --log-format=COMBINED
在浏览器中,打开http://xxxxx:8080/report.html,就能够查看实时日志了,效果以下:centos