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

~3 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

Related Articles

Email Client Configuration & Dovecot Quota/Monitoring Guide for DirectAdmin Users

This guide explains how to configure popular email clients (iPhone Mail, Thunderbird, Gmail POP/SMTP), enable Dovecot LMTP quota warnings, and check the last login time for all email accounts on a DirectAdmin server. It includes step by step instructions, recommended IMAP/SMTP settings, and useful administrative scripts.

Continue

Troubleshooting Dovecot in DirectAdmin – Fixing IMAP Errors, Authentication Issues, and SSL Certificate Checks

Dovecot is the IMAP/POP3 server used by DirectAdmin. Sometimes users encounter errors such as “Connection dropped by IMAP server” or “unknown user” during authentication. This guide explains how to fix corrupted Dovecot indexes, understand authentication logs, hide unnecessary warnings, and manually inspect SSL certificates on IMAP ports 143 and 993.

Continue

DNS Troubleshooting in DirectAdmin – When named is Running but Domains Do Not Resolve

Sometimes the named (BIND) service runs normally, yet DNS queries fail or domains do not resolve from outside. This guide provides a complete troubleshooting workflow for checking named listeners, firewall rules, named.conf configuration, DNS propagation issues, subdomain problems, resolv.conf errors, and common Apache/Nginx misconfigurations.

Continue

Managing DNS Records in DirectAdmin – Complete Practical Guide for Administrators

DirectAdmin provides a powerful DNS management system that allows administrators to control TTL values, create SRV records, enable DNSSEC, manage subdomain delegation, automate TLSA records, and perform mass DNS updates. This guide explains all essential DNS operations in DirectAdmin with real-world examples and best practices.

Continue

DNS and Nameservers in DirectAdmin – Complete, Practical, and Professional Guide

DNS is the backbone of the internet, responsible for translating domain names into IP addresses. DirectAdmin allows you to create private nameservers (ns1/ns2), manage DNS zones, configure DNS clustering, use external DNS, and troubleshoot common issues. This guide provides a complete, clear, and practical explanation of DNS concepts and their implementation in DirectAdmin.

Continue

CustomBuild in DirectAdmin – Complete Guide to Installation, Updates, Configuration, and Advanced Customization

CustomBuild is DirectAdmin’s primary software management system. It installs, updates, configures, and rebuilds essential services such as Apache, Nginx, PHP, MariaDB/MySQL, Exim, Dovecot, FTP servers, and more. Because most components are compiled from source, CustomBuild offers exceptional flexibility, fast access to new versions, and optimized performance.

Continue