maxminddb module for apache 2.4 on ubuntu error: The MaxMind DB file contains invalid metadata

maxminddb module for apache 2.4 on ubuntu error: The MaxMind DB file contains invalid metadata

这是我的系统信息:

$ apachectl -v
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2016-07-14T12:32:26

$ cat /etc/*release* | grep -i dist
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"

$ uname -r
4.4.0-57-generic

我想安装 mod_maxminddb. i installed geoipupdate as a prerequisites and configured it to include not only geolite database, but either commercial one (using this)

$ ls -l /etc/GeoIP.conf
-rw-r--r-- 1 root root 818 Dec 24 18:29 /etc/GeoIP.conf
$ ls -l /usr/share/GeoIP/
total 0
$ geoipupdate
$ ls -l /usr/share/GeoIP/
total 187444
-rw-r--r-- 1 root root 112192399 Dec 24 18:46 GeoIP2-City.mmdb
-rw-r--r-- 1 root root   3012279 Dec 24 18:46 GeoIP2-Country.mmdb
-rw-r--r-- 1 root root  47721533 Dec 24 18:46 GeoIPCity.dat
-rw-r--r-- 1 root root   1699494 Dec 24 18:45 GeoIP.dat
-rw-r--r-- 1 root root   4189407 Dec 24 18:45 GeoIPISP.dat
-rw-r--r-- 1 root root   4299547 Dec 24 18:45 GeoLiteASNum.dat
-rw-r--r-- 1 root root  17760694 Dec 24 18:45 GeoLiteCity.dat
-rw-r--r-- 1 root root   1054583 Dec 24 18:45 GeoLiteCountry.dat

然后编译安装mod_maxminddb,当apache配置为使用商业数据库时,抛出如下错误

$ apachectl -M
AH00526: Syntax error on line 12 of /etc/apache2/mods-enabled/maxminddb.conf:
MaxMindDBFile: Failed to open /usr/share/GeoIP/GeoIPCity.dat: The MaxMind DB file contains invalid metadata

但当 apache 配置为使用 geolite 数据库时,不是这种情况。

有什么想法吗?

您没有包含您的 Apache 配置,但您似乎在尝试将 mod_maxminddbGeoIPCity.dat(GeoIP Legacy)一起使用。它仅适用于 GeoIP2。将 maxminddb.conf 的第 12 行调整为使用 GeoIP2-City.mmdb