# GeoIP

*Article Topics:* [*Setup*](https://docs.toomuchmedia.com/getting-started/common-topics/setup)

{% hint style="warning" %}
**Please Note:** You will need to have purchased a license with access to the GeoIP Legacy databases otherwise you will need to set up GeoIP2 as detailed on our [GeoIP2 ](https://docs.toomuchmedia.com/setup/setup/server-setup/geoip2)page.
{% endhint %}

\
[Download](http://www.maxmind.com/app/mod_geoip) and install GeoIP from Maxmind. Please ensure that you install the **Apache** Module for GeoIP or the PECL extension, as this will not work without the GeoIP Apache API or PECL extension installed.&#x20;

Configure and test GeoIP, then find the *nats/includes* folder on your server, open the *config.php* file, and enter the following for the Apache module:

```
$config['IP_FILTER'] = 'GEOIP';
```

Or the following for the PECL extension:&#x20;

```
$config['IP_FILTER'] = 'PECL_GEOIP';
```

You can put it anywhere in the file except for after the last line.

## 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.

{% code overflow="wrap" %}

```
<?
echo 'According to geoip apache module, you are from '.apache_note("GEOIP_COUNTRY_NAME");
echo '<br>According to geoip pecl php module, you are from '.geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
?>
```

{% endcode %}

{% hint style="success" %}
**Once Completed:** Please be sure to perform this test after you install or update Maxmind's GeoIP.
{% endhint %}
