the problem:I need to detect visitor's country from his IP so I can display specific code based on the user location (different ads, etc.) in my PHP website.There is many different external services such as Ip-api.org which does this, but I want to do it internally on the server (it's faster).The question:How to do it? What do I need to install or what do google out?Update:Ideally with some open-source licence.
How to detect visitor's country from his IP for my PHP website right on the server
php;web development;server;looking for a script;ip address
https://dev.maxmind.com/geoip/geoip2/geolite2/This will give you a database of IP ranges and associated country. You can query this with PHP to find out the country for a given IP address.Make sure you read the license conditions. You will also need to keep the data updated, as otherwise it will get less accurate over time.