Hot wo install geoip and mod-geip2 to Apache in
CentOS 5.5 Linux
Today I had to to install the mod_geoip on CentOS 5.5 final, here
are the steps in which I succesfully installed the mod_geoip to
Apache.
1. Install the GeoIP and GeoIP-devel GeoIP-data and zlib-devel
packages with yum
[root@centos hipo]# yum install GeoIP GeoIP-devel GeoIP-data
zlib-devel
2. Use and set my geoip_update.sh script to constantly keep your
GeoIP Country and City database up2date
You can download the
geoip_update.sh
geoip city and countriy database update script here
You will need further to set the script to execute on your root
crontab, I've placed the following cron rules in my root's
cron;
[root@centos hipo]# echo "02 00 1 * *
/usr/sbin/geoip_update.sh >/dev/null 2>&1" | crontab
-
Accustom the cron to your time of need.
3. Install the httpd-devel and arp-devel rpms via yum, necessery
to be able to compile mod_geip after that
[root@centos hipo]# yum install httpd-devel
apr-devel
Download and unarchive the mod_geip2 source code
The latest release of mod_geoIP presently is 1.2.5, however at the
time you're trying that there could be a newer release so check
with a browser on
http://geolite.maxmind.com/download/geoip/api/mod_geoip2/ to assure
which one you'll need to download.
In my case I issued:
[root@centos hipo]# wget
http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz
[root@centos hipo]# tar xvzf mod_geoip2_1.2.5.tar.gz
[root@centos hipo]# cd mod_geoip2_1.2.5
4. Use the apache apxs (Apache Extension Tool) to compile the
mod_geoip module
[root@centos hipo]# apxs -i -a -L/usr/lib64 -I/usr/include
-lGeoIP -c mod_geoip.c
This command should install the
mod_geoip.so module to
/usr/lib64/httpd/modules/mod_geoip.so and add a
LoadModule
directive in your CentOS Apache server.
Anyhow I do recommend you check that your
/etc/httpd/conf/httpd.conf contains the following line
included:
LoadModule geoip_module
/usr/lib64/httpd/modules/mod_geoip.so
5. Put the following Apache configuration again in
/etc/httpd/conf/httpd.conf
>IfModule mod_geoip.c<
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat Standard
GeoIPDBFile /usr/share/GeoIP/GeoLiteCity.dat Standard
>IfModule<
6. In your /etc/php.ini add after the last line of the
file
extension=geoip.so
7. Restart the httpd server for the changes to take
effect
/etc/init.d/httpd restart