dunae.ca

GeoIP APIs on Dreamhost (or any shared host)

After spending the better part of a morning learning how to run a makefile with a prefix and how to run geoipupdate with a custom database, I thought my hours of research might save other non-linux types like me.

If that's you, good luck.

Getting started

Make sure you are in your home directory.

	cd ~
	

Create a directory to run local copies of packages. This is where I put my PEAR packages, shell scripts and Ruby gems as well.

	mkdir local
	chmod u+x local
	cd local
	

Create a sub-directory for source downloads.

	mkdir src
	cd src
	

Installing the GeoIP C API on Dreamhost

Download the GeoIP C API and extract it. Be sure to download a version >= 1.4.2. This version allows us to specify our own local database directory.

	wget http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.2.tar.gz
	tar xfzv GeoIP-1.4.2.tar.gz
	rm GeoIP-1.4.2.tar.gz
	cd GeoIP-1.4.2
	

Install the GeoIP C API.

	./configure --prefix=/home/USERNAME/local
	make
	make check
	make install
	

That's done. Onward...

Installing the GeoIP Perl API on Dreamhost

Download the GeoIP Perl API and extract it.

	wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz
	tar xfzv Geo-IP-1.27.tar.gz
	rm Geo-IP-1.27.tar.gz
	cd Geo-IP-1.27
	

Install the GeoIP Perl API.

	perl Makefile.PL LIBS='-L/home/USERNAME/local/lib' INC='-I/home/USERNAME/local/include' PREFIX=/home/USERNAME/local
	make
	make test
	make install
	

Configure and update your installation

Add your license key to /home/USERNAME/local/etc/GeoIP.conf. The code can be found at https://www.maxmind.com/app/my_license_key.

Update the GeoIP database.

	cd ~/local/bin/
	./geoipupdate -d /home/USERNAME/local/share/GeoIP
	

You may want to schedule your geoipupdate in your cron jobs.

Configuring GeoIP City with AWStats on Dreamhost

Edit your awstats.example.com.conf file around line 1333 and uncomment the GeoIP City plugin line.

	LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /home/USERNAME/local/share/GeoIP/GeoIPCity.dat"