|
|

03-30-2011, 10:06 AM
|
|
Senior Member
|
|
Join Date: Jan 2008
Posts: 73
|
|
GeoIP not working?
Hello, I can't seem to get GeoIP working properly for use with scripts on my server.
Basically, I've enabled the IP GeoLocation in LS, at server level, and provided the .dat for it. I've also enabled it at VHOST level, and added a GeoIPEnable On directive to the relevant htaccess.
However, scripts cannot use functions, such as -Call to undefined function- geoip_database_info().
PHPInfo shows that _SERVER[GEOIP_*] (4 entries) and it's accurate, but I can't seem to get scripts to use the functions. Any ideas?
|

03-30-2011, 11:18 AM
|
|
LiteSpeed Staff
|
|
Join Date: Oct 2010
Posts: 2,337
|
|
|
You need to add geoip support (download & install pecl geoip, load geoip.so to lsphp5 ) to lsphp5.
|

03-30-2011, 11:43 AM
|
|
Senior Member
|
|
Join Date: Jan 2008
Posts: 73
|
|
|
Hello webizen, how do I do this?
|

03-30-2011, 11:55 AM
|
|
LiteSpeed Staff
|
|
Join Date: Oct 2010
Posts: 2,337
|
|
Here is the procedure:- download pecl geoip from http://pecl.php.net/package/geoip
wget http://pecl.php.net/get/geoip-1.0.7.tgz
- build geoip.so module
tar zxf geoip-1.0.7.tgz
cd geoip-1.0.7
/usr/local/lsws/lsphp5/bin/phpize
./configure --with-php-config=/usr/local/lsws/lsphp5/bin/php-config
make
make install
Note:
a. you need to install geoip and geoip-devel rpm if not done so (yum install GeoIP-devel).
b. /usr/local/lsws/lsphp5 is the prefix of running lsphp5.
- add line "extension=geoip.so" to your lsphp5 php.ini file.
- restart lsws to make it effective.
|

03-30-2011, 11:56 AM
|
|
Senior Member
|
|
Join Date: Jan 2008
Posts: 73
|
|
|
Thanks webizen!
|

03-31-2011, 08:10 AM
|
|
Senior Member
|
|
Join Date: Jan 2008
Posts: 73
|
|
Webizen, when I try to use some functions, as in the code below,
PHP Code:
<?php if (geoip_db_avail(GEOIP_CITY_EDITION_REV1)) print geoip_database_info(GEOIP_CITY_EDITION_REV1)."<br>"; $record = geoip_record_by_name("www.google.com"); if ($record) { print_r($record); } else { print "No location found!"; } ?>
It doesn't work - the function is just failing.
|

03-31-2011, 02:33 PM
|
|
LiteSpeed Staff
|
|
Join Date: Oct 2010
Posts: 2,337
|
|
Here is what GeoIP can do in LSWS (http://www.maxmind.com/http://www.li...read.php?t=830)
Quote:
Notes
GeoIP: Set GeoIP database in Server scope and enable GeoIP for specific vhosts. Processed GeoIP data is available in the SERVER environment variables in the variable name format of 'GEOIP_XYZ' where XYZ depends on edition of Maxmind product you use. Fully compatible with scripts designed for mod_geoip.
|
Once you see the $_SERVER[GEOIP_*] variables, GeoIP in LSWS is working properly.
You are trying to use GeoIP functions (http://www.php.net/manual/en/ref.geoip.php) in PHP which is outside of LSWS. That's why suggestion to add geoip support in lsphp5 is provided. Looks like your GeoDB data file isn't not in the right place. Hence the problem. Copy the GeoIP data file to /usr/share/GeoIP directory to let PHP GeoIP extension pick them up (http://www.php.net/manual/en/geoip.setup.php).
Once done, you can verify which database is available in your system with a script like the following:
PHP Code:
<?php
$cst = array(
'GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION,
'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0,
'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0,
'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION,
'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION,
'GEOIP_CITY_EDITION_REV1' => GEOIP_CITY_EDITION_REV1,
'GEOIP_REGION_EDITION_REV1' => GEOIP_REGION_EDITION_REV1,
'GEOIP_PROXY_EDITION' => GEOIP_PROXY_EDITION,
'GEOIP_ASNUM_EDITION' => GEOIP_ASNUM_EDITION,
'GEOIP_NETSPEED_EDITION' => GEOIP_NETSPEED_EDITION,
'GEOIP_DOMAIN_EDITION' => GEOIP_DOMAIN_EDITION,
);
foreach ($cst as $k=>$v) {
echo $k.': '.geoip_db_filename($v).' '.(geoip_db_avail($v) ? 'Available':'').'<br>';
}
?>
Last edited by webizen; 03-31-2011 at 03:41 PM..
|

04-02-2011, 07:07 PM
|
|
Senior Member
|
|
Join Date: Jan 2008
Posts: 73
|
|
Hello webizen,
Thank you very much for the details - it is much appreciated.
Below's a copy of the output:
Quote:
GEOIP_COUNTRY_EDITION: /var/lib/GeoIP/GeoIP.dat Available
GEOIP_REGION_EDITION_REV0: /var/lib/GeoIP/GeoIPRegion.dat
GEOIP_CITY_EDITION_REV0: /var/lib/GeoIP/GeoIPCity.dat Available
GEOIP_ORG_EDITION: /var/lib/GeoIP/GeoIPOrg.dat
GEOIP_ISP_EDITION: /var/lib/GeoIP/GeoIPISP.dat
GEOIP_CITY_EDITION_REV1: /var/lib/GeoIP/GeoIPCity.dat Available
GEOIP_REGION_EDITION_REV1: /var/lib/GeoIP/GeoIPRegion.dat
GEOIP_PROXY_EDITION: /var/lib/GeoIP/GeoIPProxy.dat
GEOIP_ASNUM_EDITION: /var/lib/GeoIP/GeoIPASNum.dat
GEOIP_NETSPEED_EDITION: /var/lib/GeoIP/GeoIPNetSpeed.dat
GEOIP_DOMAIN_EDITION: /var/lib/GeoIP/GeoIPDomain.dat
|
|

04-15-2011, 07:51 AM
|
|
Senior Member
|
|
Join Date: Jul 2009
Posts: 53
|
|
Quote:
Originally Posted by webizen
Here is the procedure: - download pecl geoip from http://pecl.php.net/package/geoip
wget http://pecl.php.net/get/geoip-1.0.7.tgz
- build geoip.so module
tar zxf geoip-1.0.7.tgz
cd geoip-1.0.7
/usr/local/lsws/lsphp5/bin/phpize
./configure --with-php-config=/usr/local/lsws/lsphp5/bin/php-config
make
make install
Note:
a. you need to install geoip and geoip-devel rpm if not done so (yum install GeoIP-devel).
b. /usr/local/lsws/lsphp5 is the prefix of running lsphp5.
- add line "extension=geoip.so" to your lsphp5 php.ini file.
- restart lsws to make it effective.
|
I assume these instructions are outdated as the path /usr/local/lsws/lsphp5/bin no longer exists.
|

04-15-2011, 09:59 AM
|
|
LiteSpeed Staff
|
|
Join Date: Oct 2010
Posts: 2,337
|
|
As the note(b) indicates, you need to check the prefix of your running lsphp5.
Quote:
|
/usr/local/lsws/fcgi-bin/lsphp5 -i | grep prefix
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:45 AM.
|
|