Awstats Debian

How to install awstats and use it

Installation

You first, of course, need to install the corresponding package, so :

apt-get install awstats

if you didn't still install a httpd, let's do it. I did choose apache by simplicity.

Configuration file of awstats

Now, you have to edit a file, to let awstats known how to read and analyze your logs files, and where this log file is located on the server.
On a debian system, the file that needs to be edited is :

/etc/awstats/awstats.conf

First create a backup of this files, it's always a good practice to do that, before editing any important files. So :

# cp /etc/awstats/awstats.conf /etc/awstats/awstats.conf.bkp

Tell awstats which log file to analyze

You have to tell awstats where is your apache log, you have to change this line :

LogFile="/var/log/apache/access.log"

to your needs. So, if you have you log file in this directory, by instance :

/var/log/apache/

and your log file is :

my-access-log-file.log

Replace the line :

LogFile="/var/log/apache/access.log"

with this line :
LogFile="/var/log/apache/my-access-log-file.log"

Note, that there is a lot of comment in awstats configuration file, so enjoy it ! You will probably learn a lot of things !!

Tell awstats how your log file is formatted

You have to tell awstats how your log apache file are formatted, so you have to look inside your httpd.conf. You can find more information about logs formatting with apache on this page
You have to look at the directive :

LogFormat

in your apache configuration file.
So, change this line in awstats :

LogFormat=4

according to your needs.
As my formatting in httpd.conf was this one :
LogFormat "%h %l %u %t \"%r\" %>s %b %T \"%{Referer}i\" \"%{User-Agent}i\"" combined

I changed the line in awstats configuration file to this one :
LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd %other %refererquot %uaquot"

Tell awstats the name of your website

Next setting to change with awstats is the name of your website.
So, change this option :

SiteDomain=""

with the name of you web site, we will use here :

www.my-web-site.com

so edit the line with :

SiteDomain="www.my-web-site.com"

Disable dns resolution in your reports

As dns resolution can take a lot of time, and it isn't really usefull sometimes, you can choose to disable it.
So, change this line :

DNSLookup=1

to this one :

DNSLookup=0

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License