Hello, I have the same error message āError: The MM_COUNTRY_CODE $ _SERVER variable is not set. Your server may not be configured correctly.ā
Have everything as described by maxmind, created.
The Apache Module maxminddb is enabled.
MaxMindDBEnable, MaxMindDBFile and MaxMindDBEnv set on apache2.conf
I know little about Apache, but if $ _SERVER["MM_COUNTRY_CODE"] is undefined then either the Apache extension is not set up correctly or the variable is called something different than MM_COUNTRY_CODE. (You can set this up in the Matomo General Settings)
Hi Lukas,
Iām turning around this error since many days. Looking for a solution without success. Seems to me a configuration error, but cannot find where the error is. In the āsystem checkā I get:
āGeolocation works, but you are not using one of the recommended providers. If you have to import log files or do something else that requires setting IP addresses, use the PHP GeoIP 2 implementation and install [maxminddb extension.ā
If I look on System>Geolocation:
I see āGeoIp2 (Apache) brokenā and the message:
" Error: The MM_COUNTRY_CODE $_SERVER variable is not set. Your server may not be configured correctly."
And
" Matomo cannot find any GeoIP $_SERVER variables."
And if I look at āGeneral Settingsā the Variables are correctly given.
In /etc/apache2/mods-available/maxminddb.conf the module is on and the file path and dbenv are set.
In other words I dont know where to look to activate the GeoIp2 (geolocation) within Matomo.
Thanks in advance for your help.
Matomo ver. is 3.8.0
Please make sure that Apache is really putting the data into these variables. You could try creating a simple PHP script that outputs verything in $_SERVER.
<?php
var_dump($_SERVER);
This should show you a long list of variables and MM_COUNTRY_CODE should be one of them. If it isnāt, then Apache isnāt set up correctly.
Why still I have in the Matomo Administration the System check warning? By my point of view the GeoLite is correctly configured. I suspect instead something wrong elsewhere.
Are you sure those variables are set for the vhost Matomo is running on? If $_SERVER['MM_COUNTRY_CODE'] is set, it shouldnāt be reported as broken.
Just did some local tests and it worked fineā¦
Iām not an Apache guru but I think the variables are correctly set.
See attached the three screen grab which include:
VirtualHost conf
MaxMindDB conf
Matomo System settings error
Please take a look at System -> General settings. You can there setup the variables that Matomo will use. Please check if you have the correct variable names there.
Donāt know if you are still having this issue but the solution for me was to connect over public internet. I was initially testing on my vpn connection and since my ip was local, it was reporting the Plugin was broken. Like you I was able to create a test.php and it returned the correct variables. Finally I disconnected my vpn and accessed matomo over public ip, logged in as admin and the plugin was green and working. Not sure if thats just a bug in the admin ui or what. Hope that helps.
It is exactly as you wrote. Thank you!
Since Iām accessing from the local LAN (private IP address) the Apache GeoIP is broken. Once accessed from the public IP I finnally enabled successfully the GeoIP plugin wich started to show me the correct accessing location.
It is obvious that something is wrong also with the latest version of Matomo and ask the developers to look at it.
Seems to be simple to reproduce: just access from the local private IP address Matomo as administrator and try to set the GeoIP (it will be shown as broken).
But if you are in a private IP, the table cannot look up your location because there is no corresponding entry in the database.
You can overcome this be entering your own list of IP : location data in the plugin Campus IP.
This is a module for building your own list of IP : location data. You must start by already having this data in a list. You can then import it to the Campus IP module. (The module by default has no locations or IP addresses in it.) This is a third party plugin. Disclaimer: the code is not by us. It is opensource and inspectable and as of now we have not had complaints about it from any users.