Difference between revisions of "GeoIP2"
Line 29: | Line 29: | ||
== Optional Extension == | == Optional Extension == | ||
[https://github.com/maxmind/MaxMind-DB-Reader-php Download] this as either standalone or via composer. | [https://github.com/maxmind/MaxMind-DB-Reader-php Download] this as either standalone or via composer. | ||
+ | |||
Then download [https://github.com/maxmind/libmaxminddb this] and follow the instructions on the site to configure this library. (Note you will need to have a compiler such as GCC installed on your server). | Then download [https://github.com/maxmind/libmaxminddb this] and follow the instructions on the site to configure this library. (Note you will need to have a compiler such as GCC installed on your server). | ||
+ | <pre> | ||
+ | $ ./configure | ||
+ | $ make | ||
+ | $ make check | ||
+ | $ sudo make install | ||
+ | $ sudo ldconfig | ||
+ | </pre> | ||
Once the two packages are installed, you will want to run the commands to "Install Extension" | Once the two packages are installed, you will want to run the commands to "Install Extension" | ||
<pre> | <pre> | ||
Line 41: | Line 49: | ||
</pre> | </pre> | ||
− | |||
== See Also == | == See Also == |
Revision as of 17:49, 7 February 2019
Download and install the GeoIP database from Maxmind.
There is a free one available here
You will need to download the 'Country' .mmdb file for both the paid and free one
This file needs to be on your NATS installation in a path that is accessible to NATS The path will need to be specified in config->surfer->tracking GEOIP2_PHP_DATABASE_LOCATION
You will then switch the IP_FILTER to GeoIP2_PHP and store your changes
Test Code
The following PHP code will help you test GeoIP. Put it in a file, put the file on your webserver, and load its URL. It should print your country's name.
<?php include_once('../includes/procedures/GEOIP2/geoip2.phar'); $reader = new GeoIp2\Database\Reader('<PATH_TO_DB_FILE.mmdb>'); $record = $reader->country($_SERVER['REMOTE_ADDR']); $country = $record->country->isoCode; echo"$country is country";
Note: Please be sure to perform this test after you install or update Maxmind's GeoIP.
Optional Extension
Download this as either standalone or via composer.
Then download this and follow the instructions on the site to configure this library. (Note you will need to have a compiler such as GCC installed on your server).
$ ./configure $ make $ make check $ sudo make install $ sudo ldconfig
Once the two packages are installed, you will want to run the commands to "Install Extension"
cd ext phpize ./configure make make test sudo make install