Installing AWStats (Part 3)
Author: Stuart Millington Publishing date: 30.06.2003 21:35
This article describes how I set-up the Geo::IPfree module for AWStats. The purpose of this module is to locate website visitors' countries of origin by their IP address, rather than by the domain name of their ISP. Whilst this method is not perfect, it is better than assuming that a user of "someisp.com" is from the USA, which is what Webalizer does.
The first problem with installing the Geo::IPfree module is that it requires a couple of Perl modules that are not installed by default on VS's. The second problem is that the admin user does not have permission to install additional Perl modules from CPAN on a VS, as that part of the file system (the skel area) is owned by root.
So, the first thing to do is to workaround the lack of permissions by installing the CPAN modules into the "/usr/local" area, which is owned by admin. To do this you have to tell the CPAN installer to use your directories rather than the default directories.
If you have not tried the CPAN installer before, the first step is to login to your server (via SSH) as admin and allow it to set itself up with its default configuration. If you have already used the installer, you can probably skip this step.
Once you have logged in, as admin, you need to invoke the installer with "perl -MCPAN -e shell". The programme will then ask you if you are ready to configure it. Enter "no" and allow it to auto-configure with the defaults. Then, type "exit" to, well, exit the programme.
Now you need to create local directories to hold the modules. I created the following directories:
- /usr/local/lib/CPAN
- /usr/local/lib/CPAN/man/man1
- /usr/local/lib/CPAN/man/man3
The following steps use the directories above, so if you use different ones, remember to change the paths.
Re-enter the installer with "perl -MCPAN -e shell" and type (all one command):
- conf makepl_arg "LIB=/usr/local/lib/CPAN INSTALLMAN1DIR=/usr/local/lib/CPAN/man/man1 INSTALLMAN3DIR=/usr/local/lib/CPAN/man/man3"
This will, temporarily, update your install paths. To make the change permanent you need to type: "conf commit".
You can now install the modules required by Geo:IPfree. The modules and sequence below worked for me - after some trial and error. To be honest, working around the permissions problem got me a little frustrated and there is probably a far better way of installing these modules, but it got the IP analysis working on my VS and I'm not too worried about it ;)
Anyway, this is the installation sequence I used (in the CPAN installer):
- install Attribute::Handlers
- force install Attribute::Memoize
- install Geo::IPfree
A couple of notes about the install process:
- All of the installs will complain about a missing MD5 module. This is used to check the signature of downloaded modules to ensure that they are valid and genuine. I would have installed this module, but I was too frustrated to bother at this point. I will install it before I install anything else though.
- The "Attribute::Memoize" installation has to be forced because it is up to date in the root owned path. You also need to allow the installer to install any dependencies when it asks for permission.
Now that the required modules are installed, there are a few final things to do. Firstly, you need to tell "geoipfree.pm" (in the "plugins" directory under your AWStats script directory) where to find the new modules. Ideally you would change the environment variable to make a system-wide change, however that also requires root permissions. So you have to edit "geoipfree.pm" itself.
Open "geoipfree.pm" for editing (in pico, vi, etc.) and after the line:
- # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
add a new line of:
- use lib "/usr/local/lib/CPAN";
Next, near the end of "awstats.yoursite.conf" you need to uncomment the line "LoadPlugin="geoipfree" to enable the plugin.
At this point Geo::IPfree is enabled and will be used during the next scheduled AWStats cron-job. The final update I made was to delete all of the previous statistics form the AWStats output directory so that the old domain based analysis did not interfere with the IP based analysis.
After running the IP based analysis in parallel with Webalizer's domain based analysis for a week, I can see a significant difference between the two sets of results. Obviously, both have some margin of error (as do all forms of log analysis), but the IP based results appear to be more plausible - in my opinion anyway.
The copyright of some of the images that are used on this site is held by 3rd parties. The images are used for review purposes under the Fair Use / Fair Dealing provisions of copyright law. If any copyright holder objects to such use, please use the contact address below.

