[Resolved] GeoIP not working

Status
Not open for further replies.
#1
Hello,

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?

Thanks!
 
#3
PHP:
<html>
<head>
<title>What is my IP address and Country</title>
</head>
<body>
<?
    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');
?>
</body>
</html>
 
Last edited by a moderator:

NiteWave

Administrator
#4
replace above getenv by

PHP:
$_SERVER["GEOIP_COUNTRY_NAME"]
$_SERVER["REMOTE_ADDR"]
$_SERVER["HTTP_X_FORWARDED_FOR"]
?
 
Last edited by a moderator:
#6
I'm using cPanel and I tried to activate this mod on EasyApache, but it returns an error when compiling, could it be related?

Code:
-- 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 by a moderator:

NiteWave

Administrator
#7
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:
Code:
#wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#gunzip GeoLiteCity.dat.gz
then
Code:
#cp GeoLiteCity.dat /usr/local/share/GeoIP/
the test php script can be as simple as
PHP:
<?php
$country = $_SERVER["GEOIP_COUNTRY_NAME"];
echo "<br />My Country : $country<br />";
?>
 
Last edited by a moderator:

NiteWave

Administrator
#9
1.
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 ?

2.
and the test page can be phpinfo.php, it will show

Code:
_SERVER["GEOIP_COUNTRY_NAME"]
_SERVER["GEOIP_LATITUDE"]
_SERVER["GEOIP_LONGITUDE"]
_SERVER["GEOIP_COUNTRY_CODE"]
if geoIP enabled.

3. how about /usr/local/share/GeoIP/GeoIPCity.dat 's permissions from / ?
Code:
#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
?
 
Last edited by a moderator:
#13
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:
#16
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
Code:
GeoIPEnable On
in .htaccess or httpd.conf
the document is here:
http://dev.maxmind.com/geoip/legacy/mod_geoip2/

I updated /home/xxxxxx/public_html/.htaccess, and access domain.com/phpinfo.php, the
_SERVER["GEOIP_COUNTRY_NAME"]

is there.
 
Last edited by a moderator:
Status
Not open for further replies.
Top