This module uses a file based database. This database simply contains IP blocks as keys, and countries as values. This database should be more complete and accurate than reverse DNS lookups.
This module can be used to automatically select the geographically closest mirror, to analyze your web server logs to determine the countries of your visiters, for credit card fraud detection, and for software export controls.
how to quickly install the MaxMind Geo::IP Perl Module that has different usages as shown in other posts. This module should be faster than the other MaxMind perl module (Geo::IP::PurePerl) but it will require to have the GeoIP C library installed in order to be compiled.
So first we will need to install the GeoIP C library (that includes also the free GeoLite Country database). Luckily this is available in the Debian repositories so we can simply install it using:
#apt-get install libgeoip1 libgeoip-dev
Next, to install the GeoIP perl module, we need to download the perl module locally from MaxMind or from CPAN.
The latest version available at the time we wrote this post is Geo-IP-1.27, but you should get the latest version available. Uncompress it and compile it as any perl module:
For other Linux distributions you will have to use the same steps (first install the GeoIP C library and then download and compile the perl module).
Note: if you are using Centos4 then you can skip all these steps as they have packaged the perl module in the “extras” repository so you can install it by simply running:
Install dos2unix on Debian
DOS text files traditionally have carriage return and line feed pairs as their newline characters, while Unix text files have the line feed as their newline character. We often find myself needing to ‘clean-up’ some files saved with Win/DOS characters, and this can be done very easy with dos2unix. While RedHat based Linux distributions will traditionally include these small utils by default, on Debian we have to install them if needed.
The file logresolvemerge.pl included in the awstats package from Debian, needs cleaning up as showed by the error:
-bash: /usr/share/doc/awstats/examples/logresolvemerge.pl: /usr/bin/perl^M: bad interpreter: No such file or directory
The dos2unix and corresponding unix2dos, are found in the tofrodos Debian package, and to install the package just type:
#apt-get install tofrodos
Once we have dos2unix installed, I can use it to clean up very easy any file that needs that:
dos2unix logresolvemerge.pl and the offending DOS characters are gone.
Check out the manual page for full details on the usage of these little tools.
The list of files included in the tofrodos package: