使用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