Complete Guide to Website Statistics in DirectAdmin: Enabling AWStats

This article provides a comprehensive guide to managing and customizing website statistics in DirectAdmin. It covers enabling AWStats, customizing Webalizer output, enabling country-based statistics, rebuilding AWStats reports for previous months, and resolving AWStats issues when using CageFS.

Website Statistics in DirectAdminEnabling AWStats

~5 min read • Updated Mar 1, 2026

1. Enabling AWStats in DirectAdmin


DirectAdmin uses Webalizer by default, but you can switch to AWStats. This is a global setting and applies to all domains.

1.1 Install and Enable AWStats


da build set awstats yes
da build awstats

This process will:

  • Download and install AWStats
  • Add awstats=1 to directadmin.conf
  • Disable Webalizer (webalizer=0) unless manually overridden

1.2 Log Rotation Behavior

Because of AWStats’ log handling, Apache logs are not renamed to .log.1 before tallying. Instead, logs are processed in place and truncated afterward. Apache is restarted after the tally as usual.

1.3 AWStats File Locations

  • Static HTML reports: /home/user/domains/domain.com/awstats
  • Data files: /home/user/domains/domain.com/awstats/.data

This ensures stats move with the user during migrations.

1.4 Security Advantages

Unlike insecure AWStats plugins that use chmod 777, DirectAdmin stores AWStats files with root ownership and minimal permissions.

1.5 Per-User Disable Option

In user.conf:

awstats=0
---

2. Customizing Webalizer Output


DirectAdmin does not use a webalizer.conf by default. To customize Webalizer, create your own configuration file.

2.1 Create Custom Configuration

/usr/local/directadmin/data/templates/custom/webalizer.conf

Example: Enable reverse DNS lookups


DNSCache /var/lib/webalizer/|DOMAIN|.dns_cache.db
DNSChildren 10

2.2 Set Permissions


chown root:root /var/lib/webalizer
chmod 1777 /var/lib/webalizer

2.3 Running Webalizer Manually

Without custom config:


webalizer -p -n [DOMAIN] -o /home/[USER]/domains/[DOMAIN]/stats \
/var/log/httpd/domains/[DOMAIN].log

With custom config:


webalizer -c /usr/local/directadmin/data/templates/custom/webalizer.conf \
-p -n [DOMAIN] -o /home/[USER]/domains/[DOMAIN]/stats \
/var/log/httpd/domains/[DOMAIN].log

Recommended method:


echo "action=tally&value=[USER]&type=user" >> /usr/local/directadmin/data/task.queue
---

3. Enabling Country Statistics in AWStats


3.1 Quick Method (DNSLookup)

Edit:

/home/username/domains/domain.com/awstats/.data/awstats.domain.com.conf

Set:

DNSLookup=1

Note: This significantly slows down processing due to reverse DNS lookups.

3.2 Recommended Method (GeoIP Plugin)

Since MaxMind discontinued GeoIP v1, use the GeoIP plugin:

  1. Install GeoIP data
  2. Install Perl module Geo::IP
  3. Edit AWStats config:

LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"

Template for new domains:

/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf
---

4. Rebuilding AWStats HTML Reports for Previous Months


If historical data exists in .data, you can regenerate static HTML reports.

4.1 Create Script: old_awstats.sh


#!/bin/sh
if [ "$#" -eq 0 ]; then
         echo "Usage:";
         echo "    $0  ";
         exit 1;
fi

month=$1
short_year=$2
full_year=20${short_year}

for u in `ls /usr/local/directadmin/data/users`; do
{
         for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
         {
                   echo "";
                   echo "$u: $d: $month $full_year";
                   DATA=/home/$u/domains/$d/awstats/.data/awstats${month}${full_year}.${d}.txt
                   if [ ! -s $DATA ]; then
                             echo "Cannot find $DATA for $month $full_year. Skipping.";
                             continue;
                   fi

                   /usr/bin/perl /usr/local/awstats/tools/awstats_buildstaticpages.pl \
                       -config=$d -configdir=/home/$u/domains/$d/awstats/.data -update \
                       -diricons=icon -awstatsprog=/usr/local/awstats/cgi-bin/awstats.pl \
                       -dir=/home/$u/domains/$d/awstats -builddate=${short_year}${month} \
                       -year=$full_year -month=$month

                   echo "";
         }
         done;
}
done;
exit 0;

Make executable:

chmod 755 old_awstats.sh

Example:

./old_awstats.sh 04 20
---

5. Fixing AWStats Issues with CageFS


If AWStats fails with:


Can't open perl script "/usr/local/awstats/tools/awstats_buildstaticpages.pl"

It means AWStats files were not copied into the CageFS skeleton.

5.1 Edit CageFS Config

Edit:

/etc/cagefs/conf.d/directadmin.cfg

Add:


paths=/usr/local/awstats/, /usr/local/awstats-7.7/, /usr/local/awstats, /usr/local/php...

5.2 Update CageFS

/usr/sbin/cagefsctl --force-update

Verify:

ls -la /usr/share/cagefs-skeleton/usr/local

Written & researched by Dr. Shahin Siami