Linux HOWTOs

About | Home | Search


HOWTO: awstats
Description: Perl-based log file analyzer
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# awstats 6.4
# ===========
cd
test -f installed/awstats-6.4.tgz && mv installed/awstats-6.4.tgz .
test ! -f awstats-6.4.tgz &&
 wget http://download.sf.net/awstats/awstats-6.4.tgz
cd /usr/local/src
find -type d -maxdepth 1 -name "awstats-*" -exec rm -r {} \;
tar xzvf ~/awstats-6.4.tgz
cd awstats-6.4
chown -R root.root .

# Create the directories that everything will be installed in to,
# fix permissions and ownership on files and directories:
for dir in apache apache2; do
test -d /usr/local/$dir &&
 ( cd /usr/local/$dir
   mkdir -p cgi-bin/awstats htdocs/images/awstats
   test -d cgi-bin/awstats/lang && rm -r cgi-bin/awstats/lang
   test -d cgi-bin/awstats/lib && rm -r cgi-bin/awstats/lib
   test -d cgi-bin/awstats/plugins && rm -r cgi-bin/awstats/plugins
   cp -a /usr/local/src/awstats-6.4/wwwroot/cgi-bin/* \
    /usr/local/$dir/cgi-bin/awstats
   cp -a /usr/local/src/awstats-6.4/wwwroot/icon/* \
    /usr/local/$dir/htdocs/images/awstats
   chown -R root:nobody cgi-bin/awstats htdocs/images/awstats
   find cgi-bin/awstats -type d -exec chmod 750 {} \;
   find cgi-bin/awstats -type f -exec chmod 640 {} \;
   chown root:root cgi-bin/awstats/awstats.model.conf
   chmod 600 cgi-bin/awstats/awstats.model.conf
   chmod 750 cgi-bin/awstats/awstats.pl
   chown -R root:root cgi-bin/awstats/plugins/example
   chmod 700 cgi-bin/awstats/plugins/example
   chmod 600 cgi-bin/awstats/plugins/example/example.pm
   find htdocs/images/awstats -type d -exec chmod 750 {} \;
   find htdocs/images/awstats -type f -exec chmod 440 {} \; )
done

cd
mkdir -p -m 0700 installed
rm -f installed/awstats-*.tgz
mv awstats-6.4.tgz installed/

# Make sure your Apache logs are set up to be the 'combined' type, not
# 'common'.  You should have something like this set in your httpd.conf:
# CustomLog /usr/local/apache/logs/access_log combined

# In /usr/local/apache/cgi-bin/awstats is awstats.model.conf  Copy that file
# to any virtual's name you want to monitor like awstats.foo.org.conf
# Open up that config file, modify it as necessary.  You'll need to set
# at least these (with example values):
#
# LogFile="/usr/local/apache/logs/access_log-foo.org"
# SiteDomain="foo.org"
# DirData="/usr/local/apache/cgi-bin/awstats/data/foo.org"
# DirCgi="/cgi-bin/awstats"
# DirIcons="/images/awstats"
# AllowAccessFromWebToFollowingIPAddresses="192.168.0.1-192.168.0.255"
# SaveDatabaseFilesWithPermissionsForEveryone=0

# Run awstats at the commandline at midnight before your logs are rotated.
# I run a small bash script like this out of root's crontab:
# #!/bin/sh
# /usr/local/apache/cgi-bin/awstats/awstats.pl -config=foo.org -update
# /usr/local/apache/cgi-bin/awstats/awstats.pl -config=foo2.net -update
# /usr/local/apache/cgi-bin/awstats/awstats.pl -config=foo3.com -update
# find /usr/local/apache/cgi-bin/awstats/data -type f -name "awstats*.txt" -exec chown root:nobody {} \;
# find /usr/local/apache/cgi-bin/awstats/data -type f -name "awstats*.txt" -exec chmod 640 {} \;

# When you view the stats, use a URL like this:
# http://localhost/cgi-bin/awstats/awstats.pl?config=foo.org

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>