Installing mod_geoip For Lighttpd On Debian Etch
Installing mod_geoip For Lighttpd On Debian EtchVersion 1.0 This guide explains how to set up mod_geoip with lighttpd on a Debian Etch system. mod_geoip looks up the IP address of the client end user. This allows you to redirect or block users based on their country. You can also use this technology for your OpenX (formerly known as OpenAds or phpAdsNew) ad server to allow geo targeting. I will show two ways to build mod_geoip - the first way is to build a new lighttpd .deb package (including mod_geoip) which is the way I recommend. This works only if you have installed the standard Debian Etch lighttpd package. If you've compiled lighttpd yourself, then the second way is for you: it shows how to build mod_geoip.so for your lighttpd version. I do not issue any guarantee that this will work for you!
Preliminary NoteI'm assuming that you have a running Debian Etch system with a working lighttpd and PHP, e.g. as shown in this tutorial: Installing Lighttpd With PHP5 And MySQL Support On Debian Etch.
1 First Way - Build A New lighttpd .deb PackageIf you have installed the standard Debian Etch lighttpd package, you should use this way to build and install a new lighttpd .deb package including mod_geoip. First, install all prerequisites: apt-get install build-essential dpkg-dev fakeroot debhelper cdbs libssl-dev zlib1g-dev libbz2-dev libattr1-dev libpcre3-dev libmysqlclient15-dev libldap2-dev libfcgi-dev libgdbm-dev libmemcache-dev liblua5.1-0-dev dpatch patchutils pkg-config uuid-dev libsqlite3-dev libxml2-dev automake libtool libgeoip1 libgeoip-dev Then install the lighttpd source package: cd /usr/src Take a look at the current directory: ls -l server1:/usr/src# ls -l As you see, we now have the sources of lighttpd 1.4.13 (from which the standard lighttpd package for Debian Etch was built). Let's go on: cd lighttpd-1.4.13/src/ http://trac.lighttpd.net/trac/attachment/wiki/Docs/ModGeoip/mod_geoip.5.c?format=raw is for lighttpd 1.4.x. For lighttpd 1.5.x, you'd have to download http://trac.lighttpd.net/trac/attachment/wiki/Docs/ModGeoip/mod_geoip.4.c?format=raw instead. Now open Makefile.am and after the last lib_LTLIBRARIES stanza (should be the lib_LTLIBRARIES += mod_accesslog.la stanza), add the following stanza: vi Makefile.am
It should look like this:
Now go to the ../debian folder: cd ../debian/ Open lighttpd.install and add the line debian/tmp/usr/lib/lighttpd/mod_geoip.so to it: vi lighttpd.install
That's it. Now we can build the new lighttpd .deb package: cd ../ dpkg-buildpackage (At the end of the build process, you'll most likely see the following warnings which you can ignore: dpkg-genchanges ) Now go to the /usr/src directory and check its content: cd /usr/src/ server1:/usr/src# ls -l As you see, we now have new lighttpd .deb packages in that directory. Install the new lighttpd with mod_geoip as follows: dpkg -i lighttpd_1.4.13-4etch8_i386.deb Now we must configure lighttpd to use mod_geoip. First, we download the GeoIP country database: mkdir /usr/local/data Then open /etc/lighttpd/lighttpd.conf and add "mod_geoip", to the server.modules section; also add the geoip.db-filename and geoip.memory-cache directives below the server.modules section: vi /etc/lighttpd/lighttpd.conf
Restart lighttpd: /etc/init.d/lighttpd restart To see if mod_geoip is working correctly, we can create a small PHP file in one of our web spaces (e.g. /var/www) (of course, PHP must be enabled in your lighttpd installation): vi /var/www/geoiptest.php
Call that file in a browser, and it should display the SERVER array including values for GEOIP_COUNTRY_CODE, GEOIP_COUNTRY_CODE3, and GEOIP_COUNTRY_NAME (make sure that you're calling the file from a public IP address, not a local one). Array If you want to use lighttpd + mod_geoip for your OpenX ad server, make sure you select MaxMind mod_apache GeoIP under Settings > Main Settings > Geotargeting Settings. This will work for lighttod + mod_geoip as well.
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning
Learn benefits of Simpana software.
View the Gartner Video





print: 

Recent comments
21 hours 33 min ago
22 hours 27 min ago
1 day 1 hour ago
1 day 7 hours ago
1 day 7 hours ago
1 day 15 hours ago
1 day 15 hours ago
1 day 15 hours ago
1 day 17 hours ago
1 day 19 hours ago