GoAccessのインストール
(1)GoAccessのインストール
[root@almalinux ~]# dnf install goaccess -y
メタデータの期限切れの最終確認: 2:52:52 前の 2026年05月26日 13時43分24秒 に実施しました。
依存関係が解決しました。
===============================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
===============================================================================================================
インストール:
goaccess x86_64 1.10.2-2.el9 epel 681 k
トランザクションの概要
===============================================================================================================
インストール 1 パッケージ
ダウンロードサイズの合計: 681 k
インストール後のサイズ: 2.7 M
パッケージのダウンロード:
goaccess-1.10.2-2.el9.x86_64.rpm 5.1 MB/s | 681 kB 00:00
---------------------------------------------------------------------------------------------------------------
合計 1.6 MB/s | 681 kB 00:00
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
準備中 : 1/1
インストール中 : goaccess-1.10.2-2.el9.x86_64 1/1
scriptletの実行中: goaccess-1.10.2-2.el9.x86_64 1/1
検証中 : goaccess-1.10.2-2.el9.x86_64 1/1
インストール済み:
goaccess-1.10.2-2.el9.x86_64
完了しました!(2)日本語環境の確認
[root@almalinux ~]# localectl status ※ 念のために、サーバーロケール確認
System Locale: LANG=ja_JP.utf8 ← ja_JP.utf8になっていればOK
VC Keymap: jp
X11 Layout: jp設定ファイルの編集 (Apache用)
[root@almalinux ~]# vi /etc/goaccess/goaccess.conf
# The following time format works with any of the
# Apache/NGINX's log formats below.
#
time-format %H:%M:%S ※ コメントアウト
# The following date format works with any of the
# Apache/NGINX's log formats below.
#
date-format %d/%b/%Y ※ コメントアウト
# In addition to specifying the raw log/date/time formats, for
# simplicity, any of the following predefined log format names can be
# supplied to the log/date/time-format variables. GoAccess can also
# handle one predefined name in one variable and another predefined
# name in another variable.
#
log-format COMBINED ※ コメントアウトリアルタイム解析の確認
[root@almalinux ~]# goaccess /var/log/httpd/access_log
※ 画面にグラフィック化された解析結果が表示される
ダッシュボード - 解析済みリクエスト全体 (26/ 5月/2026 - 26/ 5月/2026)[表示中のパネル: ユーザー数]
合計リクエスト数 1 ユニークユーザー数 0 要求されたファイル数 1 リファラ数
有効リクエスト数 1 ログの解析時間 1s 静的ファイル数 0 ログファイルサイズ 無効リクエスト数 0 除外対象数 0 404エラー数 0 データ転送量
ログ取得元 /var/log/httpd/access_log
> 1 - 一日あたりのユニークユーザー数(クローラも含める) 合計: 1/1
[ヒット数:LINEAR:REV]
1
1 +
|
|
|
|
0 + -----------------------------------------------------------------------------------------------------
ヒット数 ヒット率(%) ユーザー数 訪問率(%) データ転送量 tx% データ
------------ ---------------- --------------- ---------------- ---------------- ------- ----
1 100.00% 0 0.00% 0.0 B 0.00% 26/ 5月/2026
[?] ヘルプ [Enter] 詳細表示 0/r - 26/ 5月/2026:16:49:57 [q] GoAccessを閉じる 1.10.矢印キーでスクロールでき、Enter キーで詳細を展開できる。
終了するときは q を押す。
HTMLレポートの作成
[root@almalinux ~]# goaccess /var/log/httpd/access_log -o /var/www/html/report.html
Cleaning up resources...ブラウザから http://[サーバーIP]/report.html にアクセスすると解析結果が表示される。
外部からのアクセスが無いので参考にならないが、こんな感じで見れます。

自動化設定
(1)更新用スクリプトの作成
[root@almalinux ~]# vi /root/update_report.sh ← 更新用スクリプト作成
#!/bin/bash
export LANG="ja_JP.UTF-8"
/usr/bin/goaccess /var/log/httpd/access_log -o /var/www/html/report.html
[root@almalinux ~]# chmod +x /root/update_report.sh ← 実行権限を付与(2)Cronへの登録
[root@almalinux ~]# crontab -e
0 * * * * /root/update_report.sh > /dev/null 2>&1(3)ログローテート設定の最適化
[root@almalinux ~]# vi /etc/logrotate.d/httpd
/var/log/httpd/*log {
daily # 毎日ローテーション
rotate 30 # 30日分保存
missingok # ファイルがなくてもエラーにしない
notifempty # 空なら処理しない
compress # 圧縮して容量節約
delaycompress # 圧縮を1日遅らせる(書き込みエラー防止)
sharedscripts
postrotate
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}
[root@almalinux ~]# logrotate -d /etc/logrotate.d/httpd ← エラーが無い事を確認
WARNING: logrotate in debug mode does nothing except printing debug messages! Consider using verbose mode (-v) instead if this is not what you want.
reading config file /etc/logrotate.d/httpd
error: /etc/logrotate.d/httpd:5 bad rotation count '30 # 30日分保存'
error: found error in /var/log/httpd/*log , skipping
Reading state from file: /var/lib/logrotate/logrotate.status
error: error opening state file /var/lib/logrotate/logrotate.status: そのようなファイルやディレクトリはありま
せん
Allocating hash table for state file, size 64 entries
Handling 1 logs
rotating pattern: /var/log/httpd/*log after 1 days (30 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/httpd/access_log
Creating new state
Now: 2026-05-26 17:02
Last rotated at 2026-05-26 17:00
log does not need rotating (log has already been rotated)
considering log /var/log/httpd/error_log
Creating new state
Now: 2026-05-26 17:02
Last rotated at 2026-05-26 17:00
log does not need rotating (log has already been rotated)


コメント