I recently moved my academic website from the math department web server to the university central web servers because I was getting tired of all the weird problems I was running into.
I’ve never really cared too much about pageview statistics or anything, but with the recent shuffle, I wanted to at least see if there were a bunch of 404 errors due to something I overlooked. So I started looking at the logs, and considered putting together a simple parser to extract and compile the 404’s. Then I found AWStats which would do it for me, plus a bunch of other stats.
Although AWStats is intended to be run as a cgi script, I didn’t want to. I was already going to have to tweak things because I don’t have root access, and there’s no point making things any more complicated than they need to be. And since my logs are only delivered to me once a day, there’s no point to being able to update my statistics on demand. Even if there were, I don’t think I see the point.
I began by following this great guide by George Notaras. Highlights:
~/local/awstats/
)~/local/awstats/statdata
)public_html/stats
). You need to copy the icons
folder from wwwroot
to here.wwwroot/cgi-bin/awstats.model.conf
to awstats.mysite.conf
(replacing mysite
with whatever you want) and edit the configuration file. The configuration file needs to remain in the same directory as awstats.pl
. The model configuration file gives you most of the information you need. Don’t forget to tell it where your log file is kept (LogFile
), what format it is in (LogType
), where the data directory you created lives (DirData
) and the location of the icons
directory (DirIcons
), relative to where the HTML files will be.In the tools
directory, there is a script called awstats_buildstaticpages.pl
. Running this will optionally run awstats
and then use the output to make all of the appropriate report pages.
Important options:
-config=mysite
to tell it what configuration file to use-update
tells it to run awstats
first, which reads the log and compiles statistics. If you don’t add this, then it will produce a report based on all the statistics compiled the last time awstats
was run.-awstatsprog=/path/to/awstats.pl
tells it the location of the awstats
script.-dir=public_html/stats
tells it where to put the html files-builddate=%YYYY%MM
tells it to include the year and month of the report in the filename of the report. This way you can have more than one month of reports at the same time. This does introduce some complications, however (see below). Also, this only affects the filenames and does not change which month and year’s statistics are generated.-month=05
tells it to compute the statistics for the month of May. Leave this off and it will do this month’s report. Of course, if you want a complete month’s report, you will have to run on the first of the next month, so you will need to specify a month.-year=2011
tells it what year to use. Mostly important to compile December’s statistics in January.Update: This bug has been fixed in more recent versions of AWStats.
Unfortunately, things didn’t work exactly like I hoped. Any time I used the -builddate
option, the links in the reports didn’t work. This is the fault of awstats_buildstaticpages.pl
.
What this script does is make repeated calls to awstats.pl
, each with a different -output
option, which creates the 10 or so different pages that awstats
can generate.
When you specify a -builddate
option, it formulates an option something like -staticlinks=mysite.201201
and passes it to awstats
.
The option should be -staticlinks=awstats.mysite.201201
instead.
If you feel at all comfortable with perl, you can fix the bug by inserting awstats.
into the appropriate place. Or you could write a script to call awstats
10 times, essentially rewriting awstats_buildstaticpages.pl
, but in your favorite language and simplified because you aren’t going to make it accept as many options. Or you could hope that the bug is fixed by the time you read this.