FreeBSD-Setting up Awstats

From IdefixWiki

Jump to: navigation, search

First install the port:

/usr/ports/net/p5-Geo-IP
/usr/ports/www/awstats

Install awstats configuration:

mkdir /usr/local/etc/awstats
cd /usr/local/etc/awstats
cp /usr/local/www/awstats/cgi-bin/awstats.model.conf .
mkdir /var/lib/awstats
ln -s /usr/local/etc/awstats /etc/awstats

Now edit our standard template /usr/local/www/awstats/cgi-bin/awstats.model.conf:

LogFile="/usr/home/http/fechner.net/logs/custom.log"
SiteDomain="__ENVNAME__"
AllowAccessFromWebToAuthenticatedUsersOnly=1
AllowAccessFromWebToFollowingAuthenticatedUsers="__REMOTE_USER"
DirData="/var/lib/awstats"

This file can be copied now to the following names: awstats.<domain>.conf

Make necessary changes in this new file like path for logfile etc.

To generate statistics edit /etc/crontab:

# Updatw awstats
30      23      *       *       *       root    /usr/local/www/awstats/tools/awstats_updateall.pl now

Make sure, that you have something like this line in your apache configuration:

CustomLog /home/http/default/logs/custom.log combined

Create a file /usr/local/etc/apache22/awstats.conf:

Alias /awstatsclasses "/usr/local/www/awstats/classes/"
Alias /awstatscss "/usr/local/www/awstats/css/"
Alias /awstatsicons "/usr/local/www/awstats/icons/"
Alias /awstats/ "/usr/local/www/awstats/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/www/awstats/">
    Options +ExecCGI
    DirectoryIndex awstats.pl
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthName stats
    AuthUserFile /usr/local/etc/apache22/htpasswd.awstats
    require valid-user
</Directory>

To load the file from apache add to the file /usr/local/etc/apache22/httpd.conf the line:

Include /usr/local/etc/apache22/awstats.conf

Now retart apache and go to the URI webside/awstats/.

Personal tools