如何安装GoAccess工具?
美国、香港服务器
如何安装GoAccess工具?
07-01 来源:
GoAccess 详细安装教程(CentOS Stream 9 / Ubuntu 22.04/24.04 两种系统)
一、CentOS Stream 9 / Rocky Linux 安装
方式 1:官方 yum 源安装(最简单)
bash
运行
# 安装EPEL软件源
dnf install epel-release -y
# 安装goaccess
dnf install goaccess -y
# 验证版本
goaccess --version
方式 2:源码编译安装(最新版本)
bash
运行
# 安装依赖
dnf install gcc ncurses-devel geoip-devel git make -y
git clone https://github.com/allinurl/goaccess.git
cd goaccess
./autogen.sh
# 开启JSON日志、GeoIP地理位置解析
./configure --enable-utf8 --enable-geoip=mmdb
make && make install
goaccess --version
二、Ubuntu 22.04 / 24.04 安装
方式 1:apt 官方源安装
bash
运行
sudo apt update
sudo apt install goaccess -y
goaccess --version
方式 2:源码编译最新版
bash
运行
sudo apt install gcc libncursesw5-dev libgeoip-dev git make autoconf -y
git clone https://github.com/allinurl/goaccess.git
cd goaccess
./autogen.sh
./configure --enable-utf8 --enable-geoip=mmdb
make && sudo make install
三、常用运行方式
1. 终端实时查看日志
bash
运行
# Nginx默认普通日志格式
goaccess /var/log/nginx/access.log
2. 生成静态 HTML 报表
bash
运行
goaccess /var/log/nginx/access.log -o /usr/share/nginx/html/report.html
3. 实时网页可视化(常驻后台)
bash
运行
goaccess /var/log/nginx/access.log \
--log-format=JSON \
--real-time-html \
--output=/usr/share/nginx/html/log.html \
--daemonize
默认监听 0.0.0.0:7890
访问 http://服务器IP/log.html 查看实时日志面板
四、配置 Nginx 日志格式匹配
1. 普通默认 Nginx 日志
启动参数:
bash
运行
goaccess /var/log/nginx/access.log --log-format=COMBINED
2. 你之前配置的 JSON 审计日志
必须指定格式:
bash
运行
goaccess /var/log/nginx/access.log --log-format=JSON
五、配置文件位置
默认配置文件:/etc/goaccess/goaccess.conf
可在这里预设日志格式、HTML 主题、IP 地理位置库等参数。
三二互联专业提供香港VPS,美国VPS主机,香港云服务器租用等业务香港美国到大陆CN2 GIA速度最快