LINUX – Setting up AWStats in debian etch

AWStats is a free and powerful log analyzer that works as a CGI or from command line.

AWStats is a free software distributed under the GNU General Public License.

We want to have AWStats working with Apache2 logs on Debian Etch.

0) First let’s check Apache2 Log Configuration in virtual host configuration (by default on /etc/apache2/sites-available/)

A commonly used format string to define log format is this one:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined

Add this and definition in your host configuration file and then get it in use with this additional row

CustomLog /var/log/apache2/access.log combined

Save and restart Apache2

# /etc/init.d/apache2 restart

1) Now install AWStats

# apt-get install awstats

2) Configure Apache2 to include AWStats

create a new config file /etc/apache2/awstats.conf with these rows:

Alias /awstatsclasses “/usr/share/awstats/lib/”
Alias /awstats-icon/ “/usr/share/awstats/icon/”
Alias /awstatscss “/usr/share/doc/awstats/examples/css”
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

Now that are settings are defined you need that apache2 is aware of these config by adding this row in the end of /etc/apache2/apache2.conf

Include /etc/apache2/awstats.conf

Apply new configs:

# /etc/init.d/apache2 reload

3) Configure AWStats

Now try to call the URL http://www.yoursite.com/awstats/awstats.pl and you will get this error:

Error: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats.

When calling the URL http://www.mysite.org/awstats/awstats.pl, awstats is looking for the configuration file name after your domain name, namely here /etc/awstats/awstats.www.yoursite.com.conf.

Copy the default awstats configuration file

cp /etc/awstats/awstats.conf /etc/awstats/awstats.www.yoursite.com.conf

And edit it checking these rows:

LogFile=“/var/log/apache2/access.log”
SiteDomain=“yoursite.com”
4) Generate fist statistics
#/usr/bin/perl /usr/lib/cgi-bin/awstats.pl -update -config=www.yoursite.com
5) Automatize statistics generation with Cron
Change the ownership of /var/log/apache2/access.log to make this file readable from user www-data
#chown root:www-data /var/log/apache2/access.log
and then modify /etc/logrotate.d/apache2 with
create 640 root www-data
Awstats automatically installs a cron job in /etc/cron.d/awstats
Edit this file and modify execution time as your needs, log file and config file:
0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.conf -a -r /var/log/apache2
/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=www.yoursite.com -update >/dev/null
Job finished!

 

Saturday, November 1st, 2008 general

No comments yet.

Leave a comment

 

Categories

AskoziaPBX

Create your full features PBX IP with voicemail and Automated Attendant with alix2d3 or alix2d2 system board.

You can find the PBX IP preconfigured image here:


And obtain all support information "how to" here: