leev / ngx_http_geoip2_module

Nginx GeoIP2 module
BSD 2-Clause "Simplified" License
974 stars 184 forks source link

Geoip2 module requires the maxminddb library #22

Closed eko closed 9 years ago

eko commented 9 years ago

Hi @leev or everyone,

I'm trying to re-compile nginx with this ngx_http_geoip2_module.

I'm trying to run the following command:

$ sudo ./configure --add-module=/opt/nginx/ngx_http_geoip2_module

but it fails on checking the Maxmind library with this output:

[...]
configuring additional modules
adding module in /opt/nginx/ngx_http_geoip2_module
checking for MaxmindDB library ... not found
./configure: error: the geoip2 module requires the maxminddb library.

As I always read the documentation, I've of course installed the libmaxminddb before and it seems to be available:

$ sudo ldconfig -p | grep maxmind
    libmaxminddb.so.0 (libc6,x86-64) => /usr/local/lib/libmaxminddb.so.0
    libmaxminddb.so (libc6,x86-64) => /usr/local/lib/libmaxminddb.so

Do you have any suggestion to help me installing it, please?

Thank you!

eko commented 9 years ago

Hi @leev, do you have any update on this issue please?

leev commented 9 years ago

The only other time this has been reported is with #10, but otherwise I'm not sure sorry.

eko commented 9 years ago

Thank you for your answer. After investigating, it looks like this is due to nginx 1.2.1 (default in Debian 7).

I've downloaded nginx 1.6.2 and it compiles like a charm.

I close this issue as I think you do not plan to support old nginx versions. Feel free to reopen :)

pkiula commented 3 years ago

This still happens with 1.18.0 as of today. libmaxminddb etc are installed:

sudo ldconfig -p | grep maxmind
    libmaxminddb.so.0 (libc6,x86-64) => /lib64/libmaxminddb.so.0

Any suggestions? Fedora 33.

daflip commented 2 years ago

Also experienced the same issue on debian buster. It seems the libmaxminddb0 package on debian is missing maxminddb.h and maxminddb_config.h which this software requires. The configuration script tests for maxmind by trying to include the header file and trying to compile whilst linking against maxminddb. make sure your maxmind configuration is good, you can test by creating this two line c file:

#include <maxminddb.h>
void main() { }

then verify it compiles using: gcc maxmindtest.c -o maxmindtest -l maxminddb .. if it does your compilation of the nginx geoip2 module should be OK (at least maxmind wise).

I ended up grabbing the maxmind header files from the maxmind git repo:

wget -O /usr/include/maxminddb.h https://raw.githubusercontent.com/maxmind/libmaxminddb/main/include/maxminddb.h
wget -O /usr/include/maxminddb_config.h https://raw.githubusercontent.com/maxmind/libmaxminddb/main/include/maxminddb_config.h.in

after this it builds me the module .. hope this helps somebody :)

lcd1232 commented 1 year ago

I started looking for the problem and found out how ld can show you what paths it's looking for:

$ ld -lmaxminddb --verbose

==================================================
ld: mode elf_x86_64
...
attempt to open /lib/x86_64-linux-gnu/libmaxminddb.so failed
...

ld is looking for libmaxminddb.so but the library creates a symlink with an extra .0 at the end (libmaxminddb.so.0). That's why we are getting this error

$ ldconfig -p | grep maxmind
    libmaxminddb.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libmaxminddb.so.0

Solution I just created a new symlink:

$ ls -lah /lib/x86_64-linux-gnu/libmaxminddb.so.0
lrwxrwxrwx 1 root root 21 Nov 11  2020 /lib/x86_64-linux-gnu/libmaxminddb.so.0 -> libmaxminddb.so.0.0.7
$ ln -s /lib/x86_64-linux-gnu/libmaxminddb.so.0.0.7 /lib/x86_64-linux-gnu/libmaxminddb.so

And it works. It was tested on Ubuntu 20.04