geoip 모듈 설치 ( yum 설치)
1 |
[root@localhost ~]# yum -y install GeoIP-* |
만약 yum 설치가 안되면 source 설치
1 2 3 4 5 |
wget http://www.maxmind.com/download/geoip/api/c/GeoIP-latest.tar.gz tar xvfz GeoIP-latest.tar.gz cd GeoIP-1.5.0/ ./configure --prefix=/usr/local/GeoIP make && make install |
php geoip 모듈설치
1 2 3 4 5 6 |
wget http://pecl.php.net/get/geoip-1.0.8.tgz tar xvfz geoip-1.0.8.tgz cd geoip-1.0.8 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-geoip=/usr/local/GeoIP make && make install |
php.ini 등록
1 2 3 4 5 6 |
vi /usr/local/Zend/etc/php.ini extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20060613/" enable_dl = On extension="geoip.so" |
#### 테스트
1 2 3 4 5 6 |
<?php $country = geoip_country_code_by_name('www.xinet.kr'); if ($country) { echo 'This host is located in: ' . $country; } ?> |
결과값 :
1 |
This host is located in: KR |