Installing AWStats at 1and1 (page 2/4)

An updated manual for the installation of advanced webserver statistics

II. Configuring AWStats

2.1. Creating config files

AWStats uses a configuration file in text format and allows you to analyze any number of subdomains/subdirectories in a given hosting account. For example: In yourdomain.com you create a webpage for yourself (yourdomain.com/yourself) and one for your dog (yourdomain.com/yourdog). You can then configure AWStats to analyze your domain in total or both of your websites (yourself and yourdog) independently. In the latter case you need to create a config-file for each of your web directories (one for yourdomain.com/yourself and one for yourdomain.com/yourdog).

The config files are placed in awstats/cgi-bin/. AWStats comes with a template (awstats.model.conf) which you can copy for each of your subdomains/subdirectories and which you have to edit according to your settings and needs. Rename the middle part of your config files according to your subdomains/subdirectories, e.g. awstats.yourself.conf and awstats.yourdog.conf:

2.2 Editing config files

This tutorial will only cover modifications to the config file that are either essential or of general interest, according to the author's opinion. There are many more options not mentioned here which allow you to further customize AWStats. In any case try to understand the modifications rather than just copying and pasting them.

Unless you edit the config files locally with a texteditor (to upload the files by FTP) use VIM on the 1and1 server:

$ vim awstats/cgi-bin/awstats.yourself.conf

Enter "i" to get into editing mode, use the cursor keys to navigate and make the necessary modifications. Then hit "[Escape]" and type ":x" to save the file and close VIM (use ":q!" if you do not intend to save your changes).

The following modifications to the config file need to be done to analyze the 1and1 webserver logfiles:

LogFile="/var/log/httpd/mylog.log"

Needs to be changed to the location of the 1and1 logfile. The 1and1 webserver creates a new logfile each day. Logfiles before the current one are gzipped. At the end of the week the daily logfiles are merged into a weekly logfile. I suggest updating AWStats once a day, based on the respective zipped logfile created the day before. This will generate less server load than updating more frequently (e.g. on an hourly basis) and no information will be missed around the server's daily change of logfiles.

The location of the logfile as given to AWStats is defined as the piped output of gunzip, which is ordered to unpack the most recent zipped logfile found in the log-directory.

LogFile="gunzip -c $(ls -t $HOME/logs/access*.gz | head -1) |"

LogFormat=1

Needs to reflect the log format of the 1and1 webserver. You can look at a logfile in a texteditor to find the following scheme (ignore linebreaks):

AWStats can be accessed from the command line to generate static (x)html-reports. Links within these static reports will have their URLs based on the relative or absolute online location of your cgi-bin directory as provided with this setting.

DirCgi="http://sxxxxxxxx.onlinehome.us/awstats/cgi-bin"

DirIcons="/icon"

As well as DirCGI this setting will only be used when generating static (x)html-reports. Name the online location of the icon directory (which contains image and icon files to be used in the reports).

DirIcons="http://sxxxxxxxx.onlinehome.us/awstats/icon"

AllowAccessFromWebToAuthenticatedUsersOnly=0

Unauthorized people should not have access to your webserver statistics. The .htaccess file which is necessary to enforce this will be dealt with later (see 3.2).

AllowAccessFromWebToAuthenticatedUsersOnly=1

AllowAccessFromWebToFollowingAuthenticatedUsers=""

Enter your FTP user-name here and follow the instructions under 3.2. This will provide access only to that specific user-account.

AllowAccessFromWebToFollowingAuthenticatedUsers="uxxxxxxxx"

OnlyFiles="REGEX[awstats\/]"

If several of your websites share a domain (yourdomain.com/yourself vs. yourdomain.com/yourdog) rather than being organised by subdomains use this filter to analyse them individually. To see your own website's statistics only rather than analysing your dog's hits, too, an adequate regular expression for your config-file would be:

OnlyFiles="REGEX[yourself\/]"

Optional changes you may consider:

If you don't want AWStats' history files to be saved in the cgi-bin directory, you can choose another location. Notice however, that due to a bug in AWStats, you should avoid using relative paths here:

If the directory configured in DirData does not exist, AWStats will fail, unless you allow for the automatic creation of the directory.

CreateDirDataIfNotExists=1

AllowToUpdateStatsFromBrowser=0

If you wish to be able to manually update AWStats from your browser, you need to change this config and you will not be able to use the $HOME variable in the config file as demonstrated in this tutorial but need to write out the path instead.

AllowToUpdateStatsFromBrowser=1

AllowFullYearView=2

Change this option, if you want to be able see statistics for the complete year rather than only for single months while using the browser interface.

AllowFullYearView=3

Lang="auto"

If your dog is a German shepherd, you might consider surprising him with a German AWStats interface when looking at his statistics: