Help - Search - Members - Calendar
Full Version: HOWTO: mod_geoip installation
The Planet Forums > System Administration > HOWTOs
jaume
I have only tested on Ensim and plain boxes .. but should work on any.

I just posted this on another thread of someone who asked me but I think this would be interesting for many others here .. specially to those who is interested on optimize their adservers.

Quoted from GeoIP website:
QUOTE
Analyze your web logs to locate your clients, geo-target banner ads, detect credit card fraud, auto-select country on forms, prevent password sharing and abuse of service, and display native language and currency.  

Obtain the Country, Region, City, Latitude, and Longitude of any IP address. We can customize MaxMind GeoIP to meet your needs.  

Our APIs are Open Source and we offer a free database that is updated monthly.


This will be specially useful to those who use the great (and best) open source free software for banner ads serving phpAdsNew (http://www.phpadsnew.com).

Ok .. here goes the How-to:

1. Get root privileges and move to an empty dir:

su -
mkdir /home/admin/geoip
cd /home/admin/geoip

2. Download and install library:

wget http://www.maxmind.com/download/geoip/api/.../c/GeoIP.tar.gz

tar xzfv GeoIP.tar.gz

cd GeoIP*

./configure
make
make check
make install

cd ..

3. Download and build Module:

mkdir mod_geoip
cd mod_geoip

wget http://www.maxmind.com/download/geoip/api/...ip_1.1.1.tar.gz

tar xzfv mod_geoip_1.1.1.tar.gz

cd mod_geoip_1.1.1

apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c

4. Add /usr/local/lib as a loadable dynamic link:

edit /etc/ld.so.conf and add /usr/local/lib at the bottom so it looks like this:

/usr/kerberos/lib
/usr/lib/mysql
/usr/X11R6/lib
/usr/local/lib

Then execute /sbin/ldconfig /etc/ld.so.conf

5. Review httpd.conf . You should have seen a backup of the httpd.conf has been made when building the module as mod_geoip info has been inserted.

You'll find 2 lines inserted about mod_geoip.
First one:

LoadModule geoip_module lib/apache/mod_geoip.so

change to

LoadModule geoip_module /usr/lib/apache/mod_geoip.so

Add below that line:

GeoIPEnable On

the the second line is OK ... just move it to the AddModule section to keep httpd.conf pretty:)

AddModule mod_geoip.c

6. Go and restart Apache and you should not get any error.
service httpd restart

Then you can set the cron jobs to get updated databases (if you got a license) or just leave as is to keep using the free one included ( they say the free one is also updated monthly .. but will need manual download )
The DareDevil
I agree that phpAdsNew is the best out there. This HOWTO will be extremely helpful, thank you!!
h4u
have you installed Geolizer too?!
jaume
QUOTE
Originally posted by h4u
have you installed Geolizer too?!

Geolizer does not use mod_geoip . Instead it patches webalizer to access directly the GeoIP.dat file.

I do not use webalizer but reading the docs it should work if your webalizer version is the required as there are both source (needs GeoIp library) and binary methods. Try it and let us know:)
MartynW
Hi Juame,

I successfully installed mod_geoip per the instructions, but can't seem to access the environment variables that it is supposed to set from within a name based virtual domain.

The following short perl .cgi script should display all $ENV variables when called from a browser:

#!/usr/bin/perl -w
print "Content-type: text/htmlnn";
print "n";
print map { "$_ = $ENV{$_}
n" } sort (keys (%ENV));
print "n";

If this is placed in a virtual sites cgi-bin then the GeoIP environment variables don't appear. However, if it's placed in a virtual sites mod_perl directory they do appear.

Any ideas?

Thanks,

Martyn
jaume
QUOTE
Originally posted by MartynW
Hi Juame,

I successfully installed mod_geoip per the instructions, but can't seem to access the environment variables that it is supposed to set from within a name based virtual domain.

The following short perl .cgi script should display all $ENV variables when called from a browser:

#!/usr/bin/perl -w
print "Content-type: text/htmlnn";
print "n";
print map { "$_ = $ENV{$_}
n" } sort (keys (%ENV));
print "n";

If this is placed in a virtual sites cgi-bin then the GeoIP environment variables don't appear.  However, if it's placed in a virtual sites mod_perl directory they do appear.

Any ideas?

Thanks,

Martyn


I can see the variables correctly from php so this will probably be some kind of prob with perl and the chroot environment. I didn't notice as I only use PHP scripts ( forgot about perl some time ago icon_smile.gif).
MartynW
Hi Jaume,

I think I've narrowed it down to being caused by .cgi's running under suexec, as if I disable suexec temporarily it works.

I don't know why suexec interferes with it though, as I would have thought that the $ENV variables were introduced at the httpd process level (i.e. as soon as a client connects to apache) before the server has dealt out whatever page the client has requested.

Martyn
jaume
QUOTE
Originally posted by MartynW
Hi Jaume,

I think I've narrowed it down to being caused by .cgi's running under suexec, as if I disable suexec temporarily it works.  

I don't know why suexec interferes with it though, as I would have thought that the $ENV variables were introduced at the httpd process level (i.e. as soon as a client connects to apache) before the server has dealt out whatever page the client has requested.  

Martyn


See this HOWTO by Yenne & Madsere:
cgi-scripts in chroot environment
http://ensim.webscorpion.com/modules.php?n...order=0&thold=0

You'll have to register to his site to see it .. it's free.
MartynW
Unfortunately it looks like a no go. I found out that suexec "cleans" unknown environment variables as part of it's behaviour. You can set which environment variables are "safe" when you compile suexec, but seeing as we don't get access to the ensimised source code I don't think that's an option.

I suppose I could modify the source for mod_geoip to stuff the country code and name into one of the ensim "safe" variables like "SITE_ROOT" or similar........

Thanks anyway,

Martyn
MartynW
That's the way to do it!

For anybody else wishing to use mod_geoip under suexec, simply edit mod_geoip.c before you run "apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c" from Jaumes how-to above.

Replace all instances of:

r->subprocess_env, "GEOIP_

with:
r->subprocess_env, "HTTP_GEOIP_

Then continue following the how-to.

This makes mod_geoip use environment variables that begin with "HTTP_" and are classed as "safe" by suexec so they won't be removed.

Martyn
alex2k
I got these errors when compile it:

QUOTE
[root@server1 mod_geoip_1.1.1]# apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
gcc -DLINUX=22 -DMOD_SSL=208112 -DEAPI -DEAPI_MM -DFD_SETSIZE=4096 -fpic -DSHARED_MODULE -I/usr/include/apache -I/usr/local/include  -c mod_geoip.c
mod_geoip.c: In function `geoip_post_read_request':
mod_geoip.c:244: `GEOIP_CITY_EDITION' undeclared (first use in this function)
mod_geoip.c:244: (Each undeclared identifier is reported only once
mod_geoip.c:244: for each function it appears in.)
apxs:Break: Command failed with rc=1


How to fix it?
Thank's....
alex2k
Problem fixed, so forget it my post above, icon_smile.gif
wshawn
After following this thread I get the following

[root@secure awstats]# ./awstats.pl -config=awstats.conf -update
Error: Plugin load for plugin 'geoip' failed with return code: Error: Can't locate Geo/IP/PurePerl.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.6.1/i386-linux /usr/lib/perl5/vendor_perl/5.6.1 /usr/lib/perl5/vendor_perl . ./lib ./plugins) at (eval 2) line 1.

I'm running ensim pro on RH 7.3.

Any one have ideas. I tried it with both the original how-to, then recompiled /re edited httpd.conf using MartynW's changes. BOth come back broken.

Any ideas?
GFED
I get to step 3... AMD Duron - 1Ghz - CPanel - 20GB HD - 512 MB RAM

root@srv01 [/tmp/mod_geoip_1.2.3]# apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
/usr/lib/httpd/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -march=i386 -mcpu=i686 -I/usr/kerberos/include -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -pthread -DNO_DBM_REWRITEMAP -I/usr/include/httpd -I/usr/local/include -c -o mod_geoip.lo mod_geoip.c && touch mod_geoip.slo
mod_geoip.c:108: parse error before "geoip_module"
mod_geoip.c:108: warning: data definition has no type or storage class
mod_geoip.c:110: parse error before "proxy_add_uri_module"
mod_geoip.c:110: warning: data definition has no type or storage class
mod_geoip.c:121: parse error before '*' token
mod_geoip.c: In function `geoip_server_config':
mod_geoip.c:122: `p' undeclared (first use in this function)
mod_geoip.c:122: (Each undeclared identifier is reported only once
mod_geoip.c:122: for each function it appears in.)
mod_geoip.c:122: warning: initialization makes pointer from integer without a cast
mod_geoip.c: In function `geoip_enable':
mod_geoip.c:138: request for member `module_index' in something not a structure or union
mod_geoip.c: In function `geoip_set_filename':
mod_geoip.c:146: request for member `module_index' in something not a structure or union
mod_geoip.c: In function `geoip_set_output':
mod_geoip.c:164: request for member `module_index' in something not a structure or union
mod_geoip.c:176: warning: passing arg 4 of `ap_log_error' makes integer from pointer without a cast
mod_geoip.c:176: warning: passing arg 5 of `ap_log_error' from incompatible pointer type
mod_geoip.c: In function `geoip_set_flags':
mod_geoip.c:184: request for member `module_index' in something not a structure or union
mod_geoip.c: At top level:
mod_geoip.c:192: warning: initialization from incompatible pointer type
mod_geoip.c:194: warning: initialization from incompatible pointer type
mod_geoip.c:196: warning: initialization from incompatible pointer type
mod_geoip.c:198: warning: initialization from incompatible pointer type
mod_geoip.c: In function `geoip_post_read_request':
mod_geoip.c:204: request for member `module_index' in something not a structure or union
mod_geoip.c:229: warning: passing arg 4 of `ap_log_error' makes integer from pointer without a cast
mod_geoip.c:229: warning: passing arg 5 of `ap_log_error' from incompatible pointer type
mod_geoip.c:237: warning: passing arg 4 of `ap_log_error' makes integer from pointer without a cast
mod_geoip.c:237: warning: passing arg 5 of `ap_log_error' from incompatible pointer type
mod_geoip.c:237: too few arguments to function `ap_log_error'
mod_geoip.c: At top level:
mod_geoip.c:331: parse error before "pool"
mod_geoip.c: In function `geoip_child_exit':
mod_geoip.c:333: `r' undeclared (first use in this function)
mod_geoip.c:333: request for member `module_index' in something not a structure or union
mod_geoip.c: At top level:
mod_geoip.c:348: parse error before "geoip_module"
mod_geoip.c:349: `this_module_needs_to_be_ported_to_apache_2_0' undeclared here (not in a function)
mod_geoip.c:349: initializer element is not constant
mod_geoip.c:349: (near initialization for `geoip_module')
mod_geoip.c:350: warning: excess elements in scalar initializer
mod_geoip.c:350: warning: (near initialization for `geoip_module')
mod_geoip.c:351: warning: excess elements in scalar initializer
mod_geoip.c:351: warning: (near initialization for `geoip_module')
mod_geoip.c:352: warning: excess elements in scalar initializer
mod_geoip.c:352: warning: (near initialization for `geoip_module')
mod_geoip.c:353: warning: excess elements in scalar initializer
mod_geoip.c:353: warning: (near initialization for `geoip_module')
mod_geoip.c:354: warning: excess elements in scalar initializer
mod_geoip.c:354: warning: (near initialization for `geoip_module')
mod_geoip.c:355: warning: excess elements in scalar initializer
mod_geoip.c:355: warning: (near initialization for `geoip_module')
mod_geoip.c:356: warning: excess elements in scalar initializer
mod_geoip.c:356: warning: (near initialization for `geoip_module')
mod_geoip.c:357: warning: excess elements in scalar initializer
mod_geoip.c:357: warning: (near initialization for `geoip_module')
mod_geoip.c:358: warning: excess elements in scalar initializer
mod_geoip.c:358: warning: (near initialization for `geoip_module')
mod_geoip.c:359: warning: excess elements in scalar initializer
mod_geoip.c:359: warning: (near initialization for `geoip_module')
mod_geoip.c:360: warning: excess elements in scalar initializer
mod_geoip.c:360: warning: (near initialization for `geoip_module')
mod_geoip.c:361: warning: excess elements in scalar initializer
mod_geoip.c:361: warning: (near initialization for `geoip_module')
mod_geoip.c:362: warning: excess elements in scalar initializer
mod_geoip.c:362: warning: (near initialization for `geoip_module')
mod_geoip.c:363: warning: excess elements in scalar initializer
mod_geoip.c:363: warning: (near initialization for `geoip_module')
mod_geoip.c:364: warning: excess elements in scalar initializer
mod_geoip.c:364: warning: (near initialization for `geoip_module')
mod_geoip.c:365: warning: excess elements in scalar initializer
mod_geoip.c:365: warning: (near initialization for `geoip_module')
mod_geoip.c:366: warning: excess elements in scalar initializer
mod_geoip.c:366: warning: (near initialization for `geoip_module')
mod_geoip.c:367: warning: excess elements in scalar initializer
mod_geoip.c:367: warning: (near initialization for `geoip_module')
mod_geoip.c:368: warning: data definition has no type or storage class
apxs:Error: Command failed with rc=65536
andreseso
The problem is that with cpanel apache is in a non standard location. The apxs you have to use is in /usr/local/apache/bin, not the one that came with the http_devel rpm

This command line worked like a charm in the mod_ip-x.x.x directory:
/usr/local/apache/bin/apxs -cia -I/usr/local/include -I/usr/local/apache/include -L/usr/local/lib -lGeoIP mod_geoip.c
I am not sure which of the two -I elements are required but it worked.


For another way of doing it check http://forums.cpanel.net/showthread.php?s=...&highlight=apxs
(registration required)

The question is the apxs which comes in the cpanel path is broken with cpanel apache. It is designed for RH apache and Ensim apache (apache versions that come in an rpm file, cpanel apache is compiled). You have to use the cpanel apache apxs which is in directory /usr/local/apache/bin

[EDIT]
mod_geoip.so is copied to /usr/local/apache/libexec/mod_geoip.so instead of to /usr/lib/apache/mod_geoip.so as in Jaume's installation in Ensim and Plain RH boxes.

This is in the cpanel apache path so you do not have to touch neither the AddModule nor the LoadModule lines.

The only modification you have to make to /etc/httpd/conf/httpd.conf
is to add the
GeoIPEnable On
line

Do not forget to add /usr/local/lib to the end of /etc/ld.so.conf and to execute as root
/sbin/ldconfig /etc/ld.so.conf
as per Jaume's instructions

That got me for a while: Missing shared libraries.
GFED
I get to the end of step 3 and start getting these errors...

apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c

root@srv01 [/home/admin/geoip/mod_geoip/mod_geoip_1.1.1]# apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
/usr/lib/httpd/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -march=i386 -mcpu=i686 -I/usr/kerberos/include -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -pthread -DNO_DBM_REWRITEMAP -I/usr/include/httpd -I/usr/local/include -c -o mod_geoip.lo mod_geoip.c && touch mod_geoip.slo
mod_geoip.c:107: parse error before "geoip_module"
mod_geoip.c:107: warning: data definition has no type or storage class
mod_geoip.c:109: parse error before "proxy_add_uri_module"
mod_geoip.c:109: warning: data definition has no type or storage class
mod_geoip.c:118: parse error before '*' token
mod_geoip.c: In function `geoip_server_config':
mod_geoip.c:119: `p' undeclared (first use in this function)
mod_geoip.c:119: (Each undeclared identifier is reported only once
mod_geoip.c:119: for each function it appears in.)
mod_geoip.c:119: warning: initialization makes pointer from integer without a cast
mod_geoip.c: In function `geoip_enable':
mod_geoip.c:133: request for member `module_index' in something not a structure or union
mod_geoip.c: In function `geoip_set_filename':
mod_geoip.c:140: request for member `module_index' in something not a structure or union
mod_geoip.c: In function `geoip_set_output':
mod_geoip.c:147: request for member `module_index' in something not a structure or union
mod_geoip.c:159: warning: passing arg 4 of `ap_log_error' makes integer from pointer without a cast
mod_geoip.c:159: warning: passing arg 5 of `ap_log_error' from incompatible pointer type
mod_geoip.c: In function `geoip_set_flags':
mod_geoip.c:165: request for member `module_index' in something not a structure or union
mod_geoip.c: At top level:
mod_geoip.c:172: warning: initialization from incompatible pointer type
mod_geoip.c:174: warning: initialization from incompatible pointer type
mod_geoip.c:176: warning: initialization from incompatible pointer type
mod_geoip.c:178: warning: initialization from incompatible pointer type
mod_geoip.c: In function `geoip_post_read_request':
mod_geoip.c:184: request for member `module_index' in something not a structure or union
mod_geoip.c:206: warning: passing arg 4 of `ap_log_error' makes integer from pointer without a cast
mod_geoip.c:206: warning: passing arg 5 of `ap_log_error' from incompatible pointer type
mod_geoip.c:206: too few arguments to function `ap_log_error'
mod_geoip.c: At top level:
mod_geoip.c:268: parse error before "pool"
mod_geoip.c: In function `geoip_child_exit':
mod_geoip.c:269: `r' undeclared (first use in this function)
mod_geoip.c:269: request for member `module_index' in something not a structure or union
mod_geoip.c: At top level:
mod_geoip.c:274: parse error before "geoip_module"
mod_geoip.c:275: `this_module_needs_to_be_ported_to_apache_2_0' undeclared here (not in a function)
mod_geoip.c:275: initializer element is not constant
mod_geoip.c:275: (near initialization for `geoip_module')
mod_geoip.c:276: warning: excess elements in scalar initializer
mod_geoip.c:276: warning: (near initialization for `geoip_module')
mod_geoip.c:277: warning: excess elements in scalar initializer
mod_geoip.c:277: warning: (near initialization for `geoip_module')
mod_geoip.c:278: warning: excess elements in scalar initializer
mod_geoip.c:278: warning: (near initialization for `geoip_module')
mod_geoip.c:279: warning: excess elements in scalar initializer
mod_geoip.c:279: warning: (near initialization for `geoip_module')
mod_geoip.c:280: warning: excess elements in scalar initializer
mod_geoip.c:280: warning: (near initialization for `geoip_module')
mod_geoip.c:281: warning: excess elements in scalar initializer
mod_geoip.c:281: warning: (near initialization for `geoip_module')
mod_geoip.c:282: warning: excess elements in scalar initializer
mod_geoip.c:282: warning: (near initialization for `geoip_module')
mod_geoip.c:283: warning: excess elements in scalar initializer
mod_geoip.c:283: warning: (near initialization for `geoip_module')
mod_geoip.c:284: warning: excess elements in scalar initializer
mod_geoip.c:284: warning: (near initialization for `geoip_module')
mod_geoip.c:285: warning: excess elements in scalar initializer
mod_geoip.c:285: warning: (near initialization for `geoip_module')
mod_geoip.c:286: warning: excess elements in scalar initializer
mod_geoip.c:286: warning: (near initialization for `geoip_module')
mod_geoip.c:287: warning: excess elements in scalar initializer
mod_geoip.c:287: warning: (near initialization for `geoip_module')
mod_geoip.c:288: warning: excess elements in scalar initializer
mod_geoip.c:288: warning: (near initialization for `geoip_module')
mod_geoip.c:289: warning: excess elements in scalar initializer
mod_geoip.c:289: warning: (near initialization for `geoip_module')
mod_geoip.c:290: warning: excess elements in scalar initializer
mod_geoip.c:290: warning: (near initialization for `geoip_module')
mod_geoip.c:291: warning: excess elements in scalar initializer
mod_geoip.c:291: warning: (near initialization for `geoip_module')
mod_geoip.c:292: warning: excess elements in scalar initializer
mod_geoip.c:292: warning: (near initialization for `geoip_module')
mod_geoip.c:293: warning: excess elements in scalar initializer
mod_geoip.c:293: warning: (near initialization for `geoip_module')
mod_geoip.c:294: warning: data definition has no type or storage class
apxs:Error: Command failed with rc=65536
GFED
QUOTE
Originally posted by andreseso
The problem is that with cpanel apache is in a non standard location.  The apxs you have to use is in /usr/local/apache/bin, not the one that came with the http_devel rpm

This command line worked like a charm in the mod_ip-x.x.x directory:
/usr/local/apache/bin/apxs -cia -I/usr/local/include -I/usr/local/apache/include -L/usr/local/lib -lGeoIP mod_geoip.c  
I am not sure which of the two -I elements are required but it worked.


For another way of doing it check http://forums.cpanel.net/showthread.php?s=...&highlight=apxs
(registration required)

The question is the apxs which comes in the cpanel path is broken with cpanel apache.  It is designed for RH apache and Ensim apache (apache versions that come in an rpm file, cpanel apache is compiled).  You have to use the cpanel apache apxs which is in directory /usr/local/apache/bin

[EDIT]  
mod_geoip.so is copied to /usr/local/apache/libexec/mod_geoip.so instead of to /usr/lib/apache/mod_geoip.so as in Jaume's installation in Ensim and Plain RH boxes.  

This is in the cpanel apache path so you do not have to touch neither the AddModule nor the LoadModule lines.

The only modification you have to make to /etc/httpd/conf/httpd.conf
is to add the  
[b]GeoIPEnable On

line

Do not forget to add /usr/local/lib to the end of /etc/ld.so.conf and to execute as root  
/sbin/ldconfig /etc/ld.so.conf
as per Jaume's instructions

That got me for a while:  Missing shared libraries. [/B]


Still having problems...

root@srv01 [/home/admin/geoip/mod_geoip/mod_geoip_1.2.3]# /usr/local/apache/bin/apxs -cia -I/usr/local/include -I/usr/local/apache/include -L/usr/local/lib -lGeoIP mod_geoip.c
gcc -DLINUX=22 -I/usr/include/gdbm -DMOD_SSL=208116 -DUSE_HSREGEX -DEAPI -fpic -DSHARED_MODULE -I/usr/local/apache/include -I/usr/local/include -I/usr/local/apache/include -c mod_geoip.c
mod_geoip.c: In function `geoip_post_read_request':
mod_geoip.c:263: `GEOIP_REGION_EDITION_REV0' undeclared (first use in this function)
mod_geoip.c:263: (Each undeclared identifier is reported only once
mod_geoip.c:263: for each function it appears in.)
mod_geoip.c:264: `GEOIP_REGION_EDITION_REV1' undeclared (first use in this function)
mod_geoip.c:282: `GEOIP_CITY_EDITION_REV0' undeclared (first use in this function)
mod_geoip.c:283: `GEOIP_CITY_EDITION_REV1' undeclared (first use in this function)
mod_geoip.c:305: warning: assignment makes pointer from integer without a cast
mod_geoip.c:315: `GEOIP_ISP_EDITION' undeclared (first use in this function)
mod_geoip.c:316: warning: assignment makes pointer from integer without a cast
apxs:Break: Command failed with rc=1
root@srv01 [/home/admin/geoip/mod_geoip/mod_geoip_1.2.3]#
GFED
QUOTE
Originally posted by alex2k
Problem fixed, so forget it my post above, icon_smile.gif


I am getting the same errors, how do you fix it?
franklo1
Hi,

I can't seem to make that to work.

<<<<<<<<

[root@ns mod_geoip_1.1.1]# apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP
mod_geoip.c
gcc -DLINUX=22 -DMOD_SSL=208112 -DEAPI -DEAPI_MM -DFD_SETSIZE=4096 -fpic -DSHARED_
MODULE -I/usr/include/apache -I/usr/local/include -c mod_geoip.c
mod_geoip.c: In function `geoip_post_read_request':
mod_geoip.c:227: `GEOIP_REGION_EDITION' undeclared (first use in this function)
mod_geoip.c:227: (Each undeclared identifier is reported only once
mod_geoip.c:227: for each function it appears in.)
mod_geoip.c:244: `GEOIP_CITY_EDITION' undeclared (first use in this function)
apxs:Break: Command failed with rc=1

>>>>>>>>>


The only location for apxs I can find on the server is /usr/sbin/apxs. I have ensim 3.1.

All help in this regard is quite appreciated

Frank.
Rubin
Hi,
I have PLESK 7 and apache 2
(apxs in /usr/local/psa/admin/bin/apxs)

[root@ns1 mod_geoip2_1.1.6]# /usr/local/psa/admin/bin/apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
cc -DHARD_SERVER_LIMIT=512 -DDEFAULT_PATH="/usr/local/psa/admin/bin:/bin:/usr/bin" -DLINUX=22 -DTARGET="httpsd" -DHAVE_SET_DUMPABLE -I/usr/include/gdbm -DMOD_SSL=208122 -DEAPI -O -pipe -W -Wall -I/home/builder/pb_work_dir/psa_aiconfig_7.5.3/psa/lib/dist/usr/include -DPLESK_Linux -I/home/builder/pb_work_dir/psa_aiconfig_7.5.3/psa/plesk-utils/include -DBSG_CR -DBSG_MSG -I/usr/include -DHAS_RPM -O3 -fexpensive-optimizations -I/usr/kerberos/include -fstrength-reduce -pipe -I/usr/include/libxml2 -Wno-unused-parameter -fpic -DSHARED_MODULE -I/usr/local/psa/admin/include -I/usr/local/include -c mod_geoip.c
mod_geoip.c:98: parse error before "geoip_module"
mod_geoip.c:98: warning: type defaults to `int' in declaration of `geoip_module'
mod_geoip.c:98: warning: data definition has no type or storage class
mod_geoip.c:100: parse error before '*' token
mod_geoip.c: In function `create_geoip_server_config':
mod_geoip.c:102: warning: implicit declaration of function `apr_pcalloc'
mod_geoip.c:102: `p' undeclared (first use in this function)
mod_geoip.c:102: (Each undeclared identifier is reported only once
mod_geoip.c:102: for each function it appears in.)
mod_geoip.c:102: warning: initialization makes pointer from integer without a cast
mod_geoip.c: At top level:
mod_geoip.c:118: parse error before "geoip_cleanup"
mod_geoip.c:119: warning: return type defaults to `int'
mod_geoip.c: In function `geoip_cleanup':
mod_geoip.c:125: `APR_SUCCESS' undeclared (first use in this function)
mod_geoip.c: At top level:
mod_geoip.c:129: parse error before '*' token
mod_geoip.c: In function `geoip_child_init':
mod_geoip.c:135: `s' undeclared (first use in this function)
mod_geoip.c:135: request for member `module_index' in something not a structure or union
mod_geoip.c:160: warning: implicit declaration of function `apr_pool_cleanup_register'
mod_geoip.c:160: `p' undeclared (first use in this function)
mod_geoip.c: In function `geoip_post_read_request':
mod_geoip.c:183: request for member `module_index' in something not a structure or union
mod_geoip.c:199: warning: passing arg 5 of `ap_log_error' from incompatible pointer type
mod_geoip.c:208: warning: passing arg 5 of `ap_log_error' from incompatible pointer type
mod_geoip.c:232: warning: implicit declaration of function `apr_table_setn'
mod_geoip.c:263: warning: implicit declaration of function `apr_table_set'
mod_geoip.c:171: warning: unused variable `gip'
mod_geoip.c: In function `set_geoip_enable':
mod_geoip.c:360: request for member `module_index' in something not a structure or union
mod_geoip.c: In function `set_geoip_filename':
mod_geoip.c:375: request for member `module_index' in something not a structure or union
mod_geoip.c:383: warning: implicit declaration of function `apr_pstrdup'
mod_geoip.c: In function `set_geoip_output':
mod_geoip.c:398: request for member `module_index' in something not a structure or union
mod_geoip.c: At top level:
mod_geoip.c:413: parse error before '*' token
mod_geoip.c: In function `make_geoip':
mod_geoip.c:417: `p' undeclared (first use in this function)
mod_geoip.c: At top level:
mod_geoip.c:431: warning: implicit declaration of function `AP_INIT_FLAG'
mod_geoip.c:431: warning: missing braces around initializer
mod_geoip.c:431: warning: (near initialization for `geoip_cmds[0]')
mod_geoip.c:431: initializer element is not constant
mod_geoip.c:431: (near initialization for `geoip_cmds[0].name')
mod_geoip.c:432: warning: implicit declaration of function `AP_INIT_TAKE12'
mod_geoip.c:432: initializer element is not constant
mod_geoip.c:432: (near initialization for `geoip_cmds[0].func')
mod_geoip.c:433: warning: implicit declaration of function `AP_INIT_ITERATE'
mod_geoip.c:433: initializer element is not constant
mod_geoip.c:433: (near initialization for `geoip_cmds[0].cmd_data')
mod_geoip.c:434: warning: braces around scalar initializer
mod_geoip.c:434: warning: (near initialization for `geoip_cmds[0].req_override')
mod_geoip.c:434: warning: initialization makes integer from pointer without a cast
mod_geoip.c:435: warning: missing initializer
mod_geoip.c:435: warning: (near initialization for `geoip_cmds[0].name')
mod_geoip.c:435: initializer element is not constant
mod_geoip.c:435: (near initialization for `geoip_cmds[0]')
mod_geoip.c:438: parse error before '*' token
mod_geoip.c: In function `geoip_register_hooks':
mod_geoip.c:440: warning: implicit declaration of function `ap_hook_post_read_request'
mod_geoip.c:440: `APR_HOOK_MIDDLE' undeclared (first use in this function)
mod_geoip.c:441: warning: implicit declaration of function `ap_hook_child_init'
mod_geoip.c: At top level:
mod_geoip.c:446: parse error before "geoip_module"
mod_geoip.c:446: warning: type defaults to `int' in declaration of `geoip_module'
mod_geoip.c:447: `STANDARD20_MODULE_STUFF' undeclared here (not in a function)
mod_geoip.c:447: initializer element is not constant
mod_geoip.c:447: (near initialization for `geoip_module')
mod_geoip.c:448: warning: excess elements in scalar initializer
mod_geoip.c:448: warning: (near initialization for `geoip_module')
mod_geoip.c:449: warning: excess elements in scalar initializer
mod_geoip.c:449: warning: (near initialization for `geoip_module')
mod_geoip.c:450: warning: excess elements in scalar initializer
mod_geoip.c:450: warning: (near initialization for `geoip_module')
mod_geoip.c:451: warning: excess elements in scalar initializer
mod_geoip.c:451: warning: (near initialization for `geoip_module')
mod_geoip.c:452: warning: excess elements in scalar initializer
mod_geoip.c:452: warning: (near initialization for `geoip_module')
mod_geoip.c:454: warning: excess elements in scalar initializer
mod_geoip.c:454: warning: (near initialization for `geoip_module')
mod_geoip.c:454: warning: data definition has no type or storage class
apxs:Break: Command failed with rc=1

Any ideas? help
wshawn
Re download the file using wget and unzip it to a temp folder. Also, be careful of version numbers. Then try to compile again. I have to assume you did not edit the code, but it is obviously trashed. My first guess is that that got a bad download.
Rubin
Thanks,
But I receive same on any file from
http://www.maxmind.com/download/geoip/api/mod_geoip2/

Other decision?
soupn
QUOTE (jaume)
1. Get root privileges and move to an empty dir:

su -
mkdir /home/admin/geoip
cd /home/admin/geoip

2. Download and install library:

wget http://www.maxmind.com/download/geoip/api/.../c/GeoIP.tar.gz

tar xzfv GeoIP.tar.gz

cd GeoIP*

./configure
make
make check
make install

cd ..

3. Download and build Module:

mkdir mod_geoip
cd mod_geoip

wget http://www.maxmind.com/download/geoip/api/...ip_1.1.1.tar.gz

tar xzfv mod_geoip_1.1.1.tar.gz

cd mod_geoip_1.1.1

apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c

4. Add /usr/local/lib as a loadable dynamic link:

edit /etc/ld.so.conf and add /usr/local/lib at the bottom so it looks like this:

/usr/kerberos/lib
/usr/lib/mysql
/usr/X11R6/lib
/usr/local/lib

Then execute /sbin/ldconfig /etc/ld.so.conf

5. Review httpd.conf . You should have seen a backup of the httpd.conf has been made when building the module as mod_geoip info has been inserted.

You'll find 2 lines inserted about mod_geoip.
First one:

LoadModule geoip_module lib/apache/mod_geoip.so

change to

LoadModule geoip_module /usr/lib/apache/mod_geoip.so

Add below that line:

GeoIPEnable On

the the second line is OK ... just move it to the AddModule section to keep httpd.conf pretty:)

AddModule mod_geoip.c

6. Go and restart Apache and you should not get any error.
service httpd restart

Then you can set the cron jobs to get updated databases (if you got a license) or just leave as is to keep using the free one included ( they say the free one is also updated monthly .. but will need manual download )


well, i´m on a cpanel 10.2.0-S83, followed this info and i´m getting

root@web [/home/admin/geoip/mod_geoip/mod_geoip_1.2.7]# apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
-bash: apxs: command not found

any help??
theuruguayan
QUOTE (soupn)
well, i´m on a cpanel 10.2.0-S83, followed this info and i´m getting

root@web [/home/admin/geoip/mod_geoip/mod_geoip_1.2.7]# apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
-bash: apxs: command not found

any help??


you need to do it in like: /usr/local/apache/bin/apxs apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
soupn
QUOTE (andreseso)
The problem is that with cpanel apache is in a non standard location. The apxs you have to use is in /usr/local/apache/bin, not the one that came with the http_devel rpm

This command line worked like a charm in the mod_ip-x.x.x directory:
/usr/local/apache/bin/apxs -cia -I/usr/local/include -I/usr/local/apache/include -L/usr/local/lib -lGeoIP mod_geoip.c
I am not sure which of the two -I elements are required but it worked.


For another way of doing it check http://forums.cpanel.net/showthread.php?s=...&highlight=apxs
(registration required)

The question is the apxs which comes in the cpanel path is broken with cpanel apache. It is designed for RH apache and Ensim apache (apache versions that come in an rpm file, cpanel apache is compiled). You have to use the cpanel apache apxs which is in directory /usr/local/apache/bin

[EDIT]
mod_geoip.so is copied to /usr/local/apache/libexec/mod_geoip.so instead of to /usr/lib/apache/mod_geoip.so as in Jaume's installation in Ensim and Plain RH boxes.

This is in the cpanel apache path so you do not have to touch neither the AddModule nor the LoadModule lines.

The only modification you have to make to /etc/httpd/conf/httpd.conf
is to add the
GeoIPEnable On
line

Do not forget to add /usr/local/lib to the end of /etc/ld.so.conf and to execute as root
/sbin/ldconfig /etc/ld.so.conf
as per Jaume's instructions

That got me for a while: Missing shared libraries.


thk you all. this one helped alot in my cpanel server.

ok its installed. now what?
soupn
.....
rgesnot
QUOTE (soupn)
well, i´m on a cpanel 10.2.0-S83, followed this info and i´m getting

root@web [/home/admin/geoip/mod_geoip/mod_geoip_1.2.7]# apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
-bash: apxs: command not found

any help??


You need to install httpd-devel (package)apxs is included in httpd-devel
Gatuku
Hi,
I followed the tutorial attempting to install geoip but i get the below error when restarting httpd on Ensim Pro 4.0.3-22.rhel.3ES

Starting httpd:
Apache 1.3 configuration directives found
please read @docdir@/migration.html


I was hoping you could tell me what i may need to do to get this to work on apache 2

Thanks.
dinfiesta
I´m getting this:

root@hercules [/home/admin/geoip/mod_geoip/mod_geoip_1.1.1]# /usr/local/apache/bin/apxs -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c
gcc -DLINUX=22 -DHAVE_SET_DUMPABLE -I/usr/include/gdbm -DMOD_SSL=208128 -DUSE_HSREGEX -DEAPI -fpic -DSHARED_MODULE -I/usr/local/apache/include -I/usr/local/include -c mod_geoip.c
mod_geoip.c: In function `geoip_post_read_request':
mod_geoip.c:227: error: `GEOIP_REGION_EDITION' undeclared (first use in this function)
mod_geoip.c:227: error: (Each undeclared identifier is reported only once
mod_geoip.c:227: error: for each function it appears in.)
mod_geoip.c:244: error: `GEOIP_CITY_EDITION' undeclared (first use in this function)
apxs:Break: Command failed with rc=1
root@hercules [/home/admin/geoip/mod_geoip/mod_geoip_1.1.1]#


Any ideas?
jamie
Hello all

I am new to this forum , am seeking your help in installing mod_geoip onto my websites

Am not unix guy , all these command you have written are plain english for me except for basics like mkdir etc

I am not able to get it to work i shall be thankful if you can help me out


here are steps which have been told and here is what i have been able to do

Am not able to cover even two steps so am taking these only


1. Get root privileges and move to an empty dir:

su -
mkdir /home/admin/geoip
cd /home/admin/geoip

I have got directory structure as

/var/www/html in
html folder i have made geoip folder as said above

then i changed directory to geoip as in cd command above



2. Download and install library:

wget http://www.maxmind.com/download/geoip/api/.../c/GeoIP.tar.gz

tar xzfv GeoIP.tar.gz

cd GeoIP*


I have been able to get the file from max server successfully


./configure

i ran this command and it some processing and last few lines were

config.status: creating libGeoIP/Makefile
config.status: creating apps/Makefile
config.status: creating conf/Makefile
config.status: creating data/Makefile
config.status: creating man/Makefile
config.status: creating test/Makefile

then it again stopped at command prompt , i guess it has been completed



make
make check

Then i ran this command and last few lines were

PASS: test-geoip
==================
All 1 tests passed
==================
make[2]: Leaving directory `/var/www/html/geoip/GeoIP-1.4.2/test'
make[1]: Leaving directory `/var/www/html/geoip/GeoIP-1.4.2/test'
Making check in man
make[1]: Entering directory `/var/www/html/geoip/GeoIP-1.4.2/man'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/var/www/html/geoip/GeoIP-1.4.2/man'
make[1]: Entering directory `/var/www/html/geoip/GeoIP-1.4.2'
make[1]: Nothing to be done for `check-am'.
make[1]: Leaving directory `/var/www/html/geoip/GeoIP-1.4.2'


make install


Now when i run this command i get errors

it says something like

Libraries have been installed in:
/usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(icon_cool.gif manual pages.
----------------------------------------------------------------------
/bin/sh ../libtool --mode=install /usr/bin/install -c libGeoIPUpdate.la /usr/local/lib/libGeoIPUpdate.la
libtool: install: warning: relinking `libGeoIPUpdate.la'
(cd /home/mytutoronline/www/geoip/GeoIP-1.4.2/libGeoIP; /bin/sh ../libtool --mode=relink gcc -g -O2 -o libGeoIPUpdate.la -rpath /usr/local/lib GeoIPUpdate.lo md5.lo -lz libGeoIP.la )
mv: cannot stat `libGeoIPUpdate.so.0.0.0': No such file or directory
libtool: install: error: relink `libGeoIPUpdate.la' with the above command before installing it
make[2]: *** [install-libLTLIBRARIES] Error 1
make[2]: Leaving directory `/var/www/html/geoip/GeoIP-1.4.2/libGeoIP'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/var/www/html/geoip/GeoIP-1.4.2/libGeoIP'
make: *** [install-recursive] Error 1




This step has not completed , whats wrong am doing?

Can you please help me out

Thank you
solokron
One problem I am finding right off the bat is GeoIP lumps both North Korea and South Korea as one. I see no differentiation for them in their GeoIPCountryWhois csv.
philfreo
Thanks - this tutorial has been very helpful to me.

I had to install some dependencies to get everything to work:
CODE
apt-get install gcc
apt-get install zlib1g-dev
apt-get install make
apt-get install apache2-threaded-dev


The last one was an attempt to get "apxs" to work. It still didn't. But then I found that in some configurations of Apache2 it is actually called "apxs2". So I just ran:
CODE
apxs2 -cia -I/usr/local/include -L/usr/local/lib -lGeoIP mod_geoip.c


Although I got the message:
apxs:Error: Activation failed for custom /etc/apache2/httpd.conf file..
apxs:Error: At least one `LoadModule' directive already has to exist..


So from that point I ignored the rest of your tutorial and followed this for my own setup:
CODE
# Enable the mod_geoip.so with Apache
cd /etc/apache2/mods-available
vim geoip.load
(and add the following text to this file and save it)
LoadModule geoip_module /usr/lib/apache2/modules/mod_geoip.so
GeoIPEnable On
GeoIPDBFile /home/geoip/GeoIP.dat
cd /etc/apache2/mods-enabled
ln -s /etc/apache2/mods-available/geoip.load geoip.load
apache2ctl restart

# Test in php file
<?php
$country_code = apache_note("GEOIP_COUNTRY_CODE");
$country_name = apache_note("GEOIP_COUNTRY_NAME");
echo $country_code . "<br />" . $country_name;
?>

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.