Skip to content

DirectAdmin stats + logs — Webalizer, AWStats, GoAccess, rotation, retention

Configure DirectAdmin web stats and log retention as production policy — pick AWStats over Webalizer, add GoAccess for real-time dashboards, set rotation that doesn't fill /home.

A customer asks for “traffic stats for last month” on their DirectAdmin-hosted site. You open their panel, click Webalizer, and see numbers that look about ten times too high — bot traffic, prefetch, and old googlebot/2.1 rules that haven’t been touched since 2014. You try AWStats; it’s been disabled for two years on this server. The raw access logs were rotated and gzipped two days ago and the oldest one on disk is from last Tuesday. Stats and logs on DirectAdmin work, but only if you actually configured them — the defaults are tuned for “as little disk as possible” and not for “answering a customer question three months later.”

What’s happening

DirectAdmin offers three web stats packages, each driven by Apache/LiteSpeed/Nginx access logs:

  • Webalizer — the default, fastest, and least informative. Aggregates raw counts without much bot filtering. Files in ~/<user>/domains/<domain>/stats/.
  • AWStats — Perl-based, dramatically better bot filtering, geolocation, search-keyword tracking. Slower to update; runs once per day. Files in ~/<user>/domains/<domain>/awstats/.
  • GoAccess — not bundled with DirectAdmin by default; it’s an external real-time log analyzer that produces an HTML dashboard from raw log files. Worth installing for the “what’s happening right now” view that neither Webalizer nor AWStats gives you.

Logs themselves are written by the web server to /var/log/httpd/domains/<domain>.log (Apache) or LiteSpeed’s equivalent. DirectAdmin runs a nightly log-processing job (/usr/local/directadmin/scripts/log_preserver.sh) that rotates, compresses, and feeds the stats packages. The default keeps a single rotated archive — yesterday’s log gets gzipped, the one from the day before disappears. That’s fine if you don’t need history; it’s a problem the first time a customer asks “what hit us last Wednesday.”

The configuration knobs are all in /usr/local/directadmin/conf/directadmin.conf and per-user package files. The right pattern is: enable AWStats by default, disable Webalizer unless a customer explicitly wants it, install GoAccess as a separate live dashboard for accounts that need it, and set log retention to at least 30 days with rotation + compression managed by logrotate, not by DirectAdmin’s nightly job.

How to verify

Which stats packages are enabled on the server:

grep -E '^(webalizer|awstats|stats)' /usr/local/directadmin/conf/directadmin.conf
# webalizer=2     # 0=off, 1=daily, 2=monthly
# awstats=1
# stats=2         # 1=Webalizer, 2=AWStats, 3=both

What each user has enabled (per-package):

grep -E '^(webalizer|awstats|stats)=' /usr/local/directadmin/data/admin/packages/*

Live state for a specific user:

USER=customer01
DOMAIN=customer01.com
ls -la /home/$USER/domains/$DOMAIN/stats/   2>/dev/null  # Webalizer
ls -la /home/$USER/domains/$DOMAIN/awstats/ 2>/dev/null  # AWStats

When was the last AWStats run for that domain:

find /home/$USER/domains/$DOMAIN/awstats/ -name 'awstats*.txt' -printf '%T+ %p\n' | sort | tail -5

Raw log status:

ls -la /var/log/httpd/domains/$DOMAIN.log* 2>/dev/null
# The .log is today, .log.1.gz is yesterday, .log.2.gz two days ago...

If you only see .log and .log.1.gz — that’s the default retention. You’re losing history every day.

How much disk current stats + logs are eating across all users:

du -sh /var/log/httpd/domains/ 2>/dev/null
du -sh /home/*/domains/*/stats/ 2>/dev/null | sort -h | tail -10
du -sh /home/*/domains/*/awstats/ 2>/dev/null | sort -h | tail -10

The fix

Set AWStats as the canonical stats package, disable Webalizer at the server level, leave it as an opt-in per-package toggle:

# /usr/local/directadmin/conf/directadmin.conf
sed -i 's/^webalizer=.*/webalizer=0/' /usr/local/directadmin/conf/directadmin.conf
sed -i 's/^awstats=.*/awstats=1/' /usr/local/directadmin/conf/directadmin.conf
sed -i 's/^stats=.*/stats=2/' /usr/local/directadmin/conf/directadmin.conf

# Reload DA config
/usr/local/directadmin/directadmin reloadconf

Per-package toggles — for packages where you charge customers for richer reporting:

# Bronze: AWStats only
echo 'webalizer=no' >> /usr/local/directadmin/data/admin/packages/bronze
echo 'awstats=yes' >> /usr/local/directadmin/data/admin/packages/bronze

# Business tier: both, and we'll add GoAccess separately
echo 'webalizer=yes' >> /usr/local/directadmin/data/admin/packages/business
echo 'awstats=yes' >> /usr/local/directadmin/data/admin/packages/business

AWStats config tuning — the default is conservative; the one you want catches modern bots, ignores prefetch headers, and treats your own IPs as internal:

# /etc/awstats/awstats.conf.local — included by all per-domain awstats configs
cat >> /etc/awstats/awstats.conf.local <<'AWSTATS'
SkipHosts="REGEX[^192\.168\.] REGEX[^10\.] REGEX[^203\.0\.113\.]"
SkipUserAgents="REGEX[^Mozilla/5\.0 \(compatible; UptimeRobot] REGEX[bingpreview] REGEX[ahrefsbot]i REGEX[semrushbot]i REGEX[mj12bot]i REGEX[dotbot]i"
LevelForRobotsDetection=2
LevelForBrowsersDetection=2
LevelForWormsDetection=2
LevelForSearchEnginesDetection=2
ShowFlagLinks="en fr es de"
AllowFullYearView=2
PurgeLogFile=0
KeepBackupOfHistoricFiles=1
AWSTATS

Stop DirectAdmin’s log_preserver from rotating logs you want to keep:

# /usr/local/directadmin/conf/log_preserver.conf  (or just disable and use logrotate instead)
echo 'log_preserver=0' >> /usr/local/directadmin/conf/directadmin.conf
/usr/local/directadmin/directadmin reloadconf

Replace it with a proper logrotate config that gives you 30 days of compressed history:

cat > /etc/logrotate.d/directadmin-domain-logs <<'LOGROTATE'
/var/log/httpd/domains/*.log
/var/log/httpd/domains/*.error.log
{
    daily
    rotate 30
    compress
    delaycompress
    missingok
    notifempty
    sharedscripts
    create 644 apache apache
    postrotate
        /sbin/service httpd reload >/dev/null 2>&1 || true
        /usr/local/lsws/bin/lswsctrl reload >/dev/null 2>&1 || true
    endscript
}
LOGROTATE

# Validate the config doesn't blow up
logrotate -d /etc/logrotate.d/directadmin-domain-logs 2>&1 | tail -20

For LiteSpeed Web Server replace the postrotate accordingly. The delaycompress is important — AWStats runs at 03:30 and needs .log.1 uncompressed; delaycompress waits one cycle before gzipping.

Install GoAccess on the server for real-time dashboards:

# AlmaLinux 9 / RHEL family
dnf -y install epel-release
dnf -y install goaccess

# Generate an HTML dashboard from a single domain's log
goaccess /var/log/httpd/domains/customer01.com.log \
  --log-format=COMBINED \
  -o /home/customer01/domains/customer01.com/public_html/_goaccess/index.html \
  --html-prefs='{"theme":"darker","perPage":15}' \
  --no-progress \
  --ignore-crawlers

Wrap that into a per-user cron that runs every 15 minutes and serves the dashboard from a password-protected directory:

#!/usr/bin/env bash
# /usr/local/directadmin/scripts/custom/goaccess-domain.sh
# Args: <user> <domain>
set -euo pipefail
USER="${1:?}"
DOMAIN="${2:?}"

LOG="/var/log/httpd/domains/${DOMAIN}.log"
OUT_DIR="/home/${USER}/domains/${DOMAIN}/public_html/_goaccess"

mkdir -p "$OUT_DIR"
chown "${USER}:${USER}" "$OUT_DIR"

# Build a rotation-aware list of input logs (last 7 days)
LOGS=( "$LOG" )
for i in 1 2 3 4 5 6 7; do
  if [[ -f "${LOG}.${i}.gz" ]]; then LOGS+=( "${LOG}.${i}.gz" ); fi
  if [[ -f "${LOG}.${i}" ]];    then LOGS+=( "${LOG}.${i}" ); fi
done

# GoAccess supports gz inputs directly
goaccess "${LOGS[@]}" \
  --log-format=COMBINED \
  -o "${OUT_DIR}/index.html" \
  --html-prefs='{"theme":"darker","perPage":15}' \
  --no-progress \
  --ignore-crawlers

chown -R "${USER}:${USER}" "$OUT_DIR"

# Drop a per-directory .htaccess if not present
if [[ ! -f "${OUT_DIR}/.htaccess" ]]; then
  cat > "${OUT_DIR}/.htaccess" <<'HTACCESS'
AuthType Basic
AuthName "GoAccess dashboard"
AuthUserFile /home/USER/.goaccess.htpasswd
Require valid-user
HTACCESS
  sed -i "s|/home/USER/|/home/${USER}/|" "${OUT_DIR}/.htaccess"
fi

Schedule:

# Every 15 minutes for the accounts that opted in
echo '*/15 * * * * root /usr/local/directadmin/scripts/custom/goaccess-domain.sh customer01 customer01.com >/dev/null 2>&1' \
  > /etc/cron.d/goaccess-customer01

A monitoring check for the AWStats pipeline — fires if AWStats hasn’t updated a domain’s history file in over 28 hours:

#!/usr/bin/env bash
# /usr/local/bin/check-awstats-fresh
set -euo pipefail
THRESHOLD=$((28 * 3600))
NOW=$(date +%s)
STALE=0
TOTAL=0
for f in /home/*/domains/*/awstats/awstats*.txt; do
  [[ -e "$f" ]] || continue
  TOTAL=$((TOTAL+1))
  mtime=$(stat -c %Y "$f")
  if (( NOW - mtime > THRESHOLD )); then
    echo "STALE: $f ($(date -d @$mtime))"
    STALE=$((STALE+1))
  fi
done
echo "checked $TOTAL files, $STALE stale"
[[ $STALE -gt 0 ]] && exit 1 || exit 0

Hook it into Prometheus textfile collector or your check_mk / Nagios setup so a stale AWStats history fires an alert.

Two operational rules: never enable both Webalizer and AWStats on a tier that’s price-sensitive — the two together can quadruple the disk usage in stats files alone, especially for high-traffic domains. And never let DirectAdmin’s log_preserver and your own logrotate config run on the same log files; pick one, document it in your runbook, and disable the other. The race between them silently shortens log retention to “the first one that fires.”

DirectAdmin shared hosting with disciplined stats + log retention and AWStats freshness alerts is part of how we operate the panel under Managed Cloud Ops with full monitoring coverage. Book a panel hygiene review if your logs and stats have been on autopilot for a while.