If you need to install the excellent mod_geoip2 extension for Apache2 then it can be done fairly painlessly. First off, we need to make sure that we have gcc installed:
gcc --version
If you don’t have it then you could ‘yum install gcc’, but I prefer to install all development tools because they include gcc anyway:
yum groupinstall 'Development Tools'
Install the GeoIP development package
yum install geoip-devel
Install mod_geoip2 by fetching the latest version with wget. To check the latest version, take a look here first:
https://github.com/maxmind/geoip-api-mod_geoip2/releases
I’m installing 1.2.10 here with this, but replace the code in lines 1, 2 and 3 here with their latest version:
wget https://github.com/maxmind/geoip-api-mod_geoip2/archive/1.2.10.tar.gz tar -zxvf 1.2.10.tar.gz cd geoip-api-mod_geoip2-1.2.10
Now we use the apxs (Apache Extension Tool) to build our extension modules for Apache:
apxs -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c mod_geoip.c
If you haven’t got apxs then you’ll need to install httpd-devel.
Be aware that this overwrites httpd so backup your server in case this fails or you get strange results.
yum install httpd-devel
If this fails with “Error: Nothing to do”, then it’s fairly common. You’ll probably find that /etc/yum.conf is blocking the installation. We can get around this by either editing the configuration file or typing:
yum --disableexcludes=all install httpd-devel
You should now have mod_geoip2 installed on your server!