[solved] GeoIP not working

Discussion in 'Install/Configuration' started by sirjuninho, May 24, 2014.

  1. sirjuninho

    sirjuninho Member


    I did this:
    lsws admin console->Server->General
    ->Enable IP GeoLocation:Yes

    lsws admin console->Server->General
    ->IP to GeoLocation DB: Add
    DB File Path: /usr/local/share/GeoIP/GeoIPCity.dat
    DB Cache Type: MemoryCache

    But still not working...
    Do I need to do anything else?

  2. NiteWave

    NiteWave Administrator

    the settings should be enough.
    how do you know it's not working ?
  3. sirjuninho

    sirjuninho Member

    <title>What is my IP address and Country</title>
    if (getenv(HTTP_X_FORWARDED_FOR)) {
    $pipaddress = getenv(HTTP_X_FORWARDED_FOR);
    $ipaddress = getenv(REMOTE_ADDR);
    echo "Your Proxy IP address is : ".$pipaddress. " (via $ipaddress) " ;
    } else {
    $ipaddress = getenv(REMOTE_ADDR);
    echo "My IP address is : $ipaddress";
    $country = getenv(GEOIP_COUNTRY_NAME);
    echo "<br />My Country : $country<br />";
    echo date('l jS \of F Y h:i:s A');

  4. NiteWave

    NiteWave Administrator

    replace above getenv by
  5. sirjuninho

    sirjuninho Member

    Same thing.
  6. sirjuninho

    sirjuninho Member

    I'm using cPanel and I tried to activate this mod on EasyApache, but it returns an error when compiling, could it be related?

    -- Begin step 'APXSing mod_geoip into apache' --
    /usr/local/apache/build/libtool --silent --mode=compile gcc -std=gnu99 -prefer-pic -m64 -fPIC -DPIC -DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/local/apache/include -I/usr/local/apache/include -I/usr/local/apache/include -I/opt/geoip/include -c -o mod_geoip.lo mod_geoip.c && touch mod_geoip.slo
    mod_geoip.c: In function 'geoip_header_parser':
    mod_geoip.c:323: error: 'conn_rec' has no member named 'remote_ip'
    mod_geoip.c:326: warning: implicit declaration of function 'ap_add_common_vars'
    mod_geoip.c:341: error: 'conn_rec' has no member named 'remote_ip'
    apxs:Error: Command failed with rc=65536
    !! '/usr/local/apache/bin/apxs -i -a -L/opt/geoip/lib -I/opt/geoip/include -lGeoIP -c mod_geoip.c' failed with exit code '256' !!
    !! Restoring original working apache !!
    Last edited: May 24, 2014
  7. NiteWave

    NiteWave Administrator

    in this case, no need to compile this mod in easyapache. the GeoIP is built-in function of litespeed.

    can you check /usr/local/share/GeoIP/GeoIPCity.dat ?

    here's one works under my test before:
    #wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
    #gunzip GeoLiteCity.dat.gz

    #cp GeoLiteCity.dat /usr/local/share/GeoIP/

    the test php script can be as simple as
    $country = $_SERVER["GEOIP_COUNTRY_NAME"];
    echo "<br />My Country : $country<br />";
  8. sirjuninho

    sirjuninho Member

    Not working yet :(
  9. NiteWave

    NiteWave Administrator

    from this screenshot http://www.litespeedtech.com/suppor...g-litespeed-for-high-traffic.8688/#post-79310
    you have 2 DB file configured. have you tried to delete one and restart litespeed ?

    and the test page can be phpinfo.php, it will show
    if geoIP enabled.

    3. how about /usr/local/share/GeoIP/GeoIPCity.dat 's permissions from / ?
    #ls -ald /usr
    #ls -ald /usr/local
    #ls -ald /usr/local/share
    #ls -ald /usr/local/share/GeoIP
    #ls -ald /usr/local/share/GeoIP/GeoIPCity.dat
  10. sirjuninho

    sirjuninho Member

    1 - Yes


    3 - Permissions are correct.
  11. NiteWave

    NiteWave Administrator

    how about disable geoip in php?

    e.g., comment out
    in php.ini
  12. sirjuninho

    sirjuninho Member

    Which php.ini?
  13. sirjuninho

    sirjuninho Member

    I changed this php.ini: /usr/local/lsws/php/php.ini

    I didn't found "extension=geoip.so", so I added it and restarted litespeed but still nothing.
    Last edited: May 25, 2014
  14. NiteWave

    NiteWave Administrator

    can you PM me the access to your server ?
    let me see what's special on the server.
  15. sirjuninho

    sirjuninho Member

  16. NiteWave

    NiteWave Administrator

    logging on the server and debug ... finally make it working,

    for lsws native vhost, GeoIP is enabled automatically if server level geoip enabled.

    for vhost from apache's httpd.conf, need add
    GeoIPEnable On
    in .htaccess or httpd.conf
    the document is here:

    I updated /home/xxxxxx/public_html/.htaccess, and access domain.com/phpinfo.php, the

    is there.
  17. sirjuninho

    sirjuninho Member

    Thanks a lot NiteWave!

Share This Page