Last active
June 27, 2021 09:16
-
-
Save vordan/26d4ee244db26e9f8cac2d3360fb710d to your computer and use it in GitHub Desktop.
Installing PHP GeoIP on UbuntuTo make GeoIP work on PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installing PHP GeoIP on Ubuntu To make GeoIP work on PHP | |
# all the functions in http://php.net/manual/en/book.geoip.php | |
# php5-geoip and GeoCityLite.dat must be installed. | |
apt-get install php5-geoip | |
mkdir /usr/local/share/GeoIP | |
cd /usr/share/local/GeoIP | |
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | |
gunzip GeoLiteCity.dat.gz | |
service apache2 restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip_address = $_SERVER['REMOTE_ADDR']; | |
echo"$ip_address, "; | |
$ip_country = geoip_country_code_by_name ($ip_address); | |
echo"$ip_country"; | |
// See PHP manual for more functions http://php.net/manual/en/ref.geoip.php like city or ISP. | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment