Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I just installed mod_geoip on a dedicated server, I did something like this:

cd /usr/share/GeoIP/
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d GeoIP.dat.gz 

wget http://twiki.cpanel.net/twiki/pub/EasyApache3/CustomMods/custom_opt_mod-mod_geoip.tar.gz
tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-mod_geoip.tar.gz

Then i rebuilded apache using whm easyapache and checking the mod_geoip checkbox. After that was done I added this to the httpd.conf file:

LoadModule geoip_module /usr/local/apache/modules/mod_geoip.so
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat

I made a simple php file with <? print_r( $_SERVER ); ?>, and the only geoip related thing I see is [GEOIP_ADDR] => 111.222.333.444, but I don't see the [GEOIP_COUNTRY_CODE] variable that I need to use.

I have made this same process in other servers and it worked well, what am I missing?

share|improve this question
    
Have you tried other IP addresses? –  Ladadadada Jul 17 '12 at 6:09
add comment

1 Answer

If the environment variables show up with other IP addresses, it's probably safe to say that the GeoIP database you're using just doesn't have a country entry for that IP address.

If it doesn't show up for ANY IP address, it is possible that the database may be corrupted, or Apache doesn't have permission to read the database.

I've never used the mod_geoip module for Apache before, but since you're using PHP I've had excellent results with the PECL GeoIP Library, and specifically, the geoip_country_code_by_name function.

Hope this helps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.