Linux Install GeoIP

Source: Internet
Author: User
Tags geoip ip country cpanel

  1. Installation method

    http://php.net/manual/en/geoip.installation.php
    Introduction to PHP Functions in GeoIP:
    http://php.net/manual/en/book.geoip.php
    If the CentOS installation prompt does not have a package, perform the following:
    RPM-IVH http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/6/i386/epel-release-6-8.noarch.rpm
    Cpanel installation is not successful please refer to the link:
    Http://infantiablue.tumblr.com/post/264539259/install-geoip-on-cpanel-centos-server

  2. Case
    <?PHP $countryArray=Array ('USA'   //states,'GBR'   //Kingdom,'AUT'   //Australia,'DEU'   //Germany,'ITA'   //Italy,'CAN'   //Canada,'FRA'   //France,'NZL'   //New Zealand,'JPN'   //Japan,'ESP'   //Spain,'CHN'   // China    ); $fileName= $_get['FileName']; if(Isset ($fileName)) {$country _code= Geoip_country_code3_by_name ($_server["REMOTE_ADDR"]); if(In_array ($country _code, $countryArray)) header ("location:http://www.google.com/". $fileName); ElseHeader ("location:http://www.baidu.com/". $fileName);}?>
    PHP for GeoIP

    Save the above code in the php file, the command is file.php.
    Visit: HTTP://WWW.YOUWEBSITE.COM/FILE.PHP?FILENAME=ABC
    If the IP country visited is in the Countryarray list, the link jumps to: http://www.google.com/abc
    If it is not part of the Countryarray list, link to: HTTP://WWW.BAIDU.COM/ABC

  3. To verify that the GeoIP is valid function
    echo $_server["REMOTE_ADDR"]. ' <br> ';
    $country _code = Geoip_country_code3_by_name ($_server["REMOTE_ADDR"]);
    $country _code = geoip_country_code3_by_name (' 58.186.0.0 ');
    echo $country _code. ' <br> ';

Linux Install GeoIP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.