Debian 9: Apache 2 Using mod_maxminddb

Discussion in 'Tips/Tricks/Mods' started by ztk.me, Jul 16, 2018.

  1. ztk.me

    ztk.me ISPConfig Developer ISPConfig Developer

    There is no much support for the GEO-IP module using maxminddb. If you don't use geoip, you won't need that, if you do, you might :)

    Code:
    apt-get install git apache2-dev build-essential libmaxminddb-dev
    cd /usr/local/src/
    
    Now use either
    git clone https://github.com/maxmind/mod_maxminddb.git
    or
    git clone https://github.com/cztk/mod_maxminddb.git
    to get a patched module, see the commits, for some they might be useful. up to you

    Code:
    cd mod_maxminddb
    ./bootstrap
    ./configure
    make
    make install
    
    map your infos you need ( check the docs or source for more examples )
    /etc/apache2/mods-available/maxminddb.conf:
    If you have no subscription you need a little cronjob-helper:

    /etc/cron.daily/maxminddb:
    Code:
    #!/bin/sh
    
    if [ ! -d "/usr/local/share/maxminddb/" ]; then
        mkdir -p /usr/local/share/maxminddb
    fi
    
    wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz -O /tmp/GeoLite2-City.tar.gz
    tar -xf /tmp/GeoLite2-City.tar.gz -C /tmp/
    find /tmp/GeoLite2-City_* | grep "GeoLite2-City.mmdb" | xargs -I{} mv {} /usr/local/share/maxminddb/GeoLite2-City.mmdb
    
    wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz -O /tmp/GeoLite2-Country.tar.gz
    tar -xf /tmp/GeoLite2-Country.tar.gz -C /tmp/
    find /tmp/GeoLite2-Country_* | grep "GeoLite2-Country.mmdb" | xargs -I{} mv {} /usr/local/share/maxminddb/GeoLite2-Country.mmdb
    
    wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz -O /tmp/GeoLite2-ASN.tar.gz
    tar -xf /tmp/GeoLite2-ASN.tar.gz -C /tmp/
    find /tmp/GeoLite2-ASN_* | grep "GeoLite2-ASN.mmdb" | xargs -I{} mv {} /usr/local/share/maxminddb/GeoLite2-ASN.mmdb
    
    rm -rf /tmp/GeoLite2-*
    service apache2 reload
    
    Code:
    chmod +x /etc/cron.daily/maxminddb
    a2enmod maxminddb
    /etc/cron.daily/maxminddb
    service apache2 restart
    
     
    Last edited: Jul 18, 2018
    Jesse Norell and till like this.

Share This Page