¾ÆÆÄÄ¡¿¡ GeoIP ¸ðµâ ¼³Ä¡ÇÏ´Â ¹æ¹ý
GeoIP ¶õ MaxMind ¿¡¼ Á¦°øÇÏ´Â ±¹°¡º°·Î IP¸¦ È®ÀÎÇÒ ¼ö ÀÖ´Â ¿ÀǼҽº ¶óÀ̺귯¸®·Î À̸¦ ÀÌ¿ëÇÏ¿© ¼¹ö¿¡ Á¢±Ù ÇÏ´Â ¾ÆÀÌÇǸ¦ ±¹°¡º°·Î °ü¸®ÇÒ ¼ö ÀÖ½À´Ï´Ù.
http://www.maxmind.com
(1) GeoIP C API ¼³Ä¡Çϱâ
1.
- GeoIP C API¸¦ ´Ù¿î ¹Þ¾Æ ¼³Ä¡ ÇÕ´Ï´Ù.
http://geolite.maxmind.com/download/geoip/api/c/
#wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
2
- ¾ÐÃàÀ» ÇØÁ¦ ÇÕ´Ï´Ù.
#tar zxvf GeoIP-1.4.6.tar.gz
3.
- ÇØÁ¦µÈ µð·ºÅ丮·Î À̵¿ ÈÄ ¼³Ä¡ µð·ºÅ丮¸¦ ÁöÁ¤ÇÏ¿© ./configure ÇÕ´Ï´Ù.
#cd cd GeoIP-1.4.6
#./configure --prefix=/usr/local/GeoIP
4.
- ÄÄÆÄÀÏ ¹× ¼³Ä¡¸¦ ÁøÇà ÇÕ´Ï´Ù.
#make && make install
5.
GeoIPÀÇ ip ¸ñ·ÏÀ» ÃÖ½ÅÁ¤º¸·Î °»½ÅÇϱâ À§ÇÏ¿© GeoIP.dat ¸¦ ´Ù¿î¹Þ¾Æ ¼³Ä¡µÈ À§Ä¡¿¡ º¹»ç ÇÕ´Ï´Ù.
- ±¹°¡ Á¤º¸ ´Ù¿î·Îµå
#wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
- µµ½Ã Á¤º¸ ´Ù¿î·Îµå
#wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
- ¾ÐÃà ÇØÁ¦
#gzip -d GeoIP.dat.gz
#gzip -d GeoLiteCity.dat.gz
- ÇØÁ¦µÈ ÆÄÀÏÀ» GeoIP°¡ ¼³Ä¡µÈ À§Ä¡¿¡ µ¤¾î¾²±â
#cp -a GeoIP.dat /usr/local/GeoIP/share/GeoIP/
#cp -a GeoLiteCity.dat /usr/local/GeoIP/share/GeoIP/
(2)
geoip¸ðµâÀ» ¾ÆÆÄÄ¡¿¡ ¼³Ä¡Çϱâ.
1.mod_geoip¸¦ ´Ù¿î ¹Þ½À´Ï´Ù.
¾ÆÆÄÄ¡ 1.x ¿ë
http://geolite.maxmind.com/download/geoip/api/mod_geoip/
¾ÆÆÄÄ¡ 2.x ¿ë
http://geolite.maxmind.com/download/geoip/api/mod_geoip2/
ex)¾ÆÆÄÄ¡ 2.x¿ë ´Ù¿î·Îµå
#wget http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz
2.
¾ÐÃàÀ» ÇØÁ¦ ÇÕ´Ï´Ù.
#tar zxvf mod_geoip2_1.2.5.tar.gz
3.
ÇØÁ¦µÈ À§Ä¡·Î À̵¿ ÈÄ cÆÄÀÏÀ» apxs¸¦ ÀÌ¿ëÇÏ¿© ¼³Ä¡ ÇÕ´Ï´Ù.
#cd mod_geoip2_1.2.5
#[¾ÆÆÄÄ¡ apxs°æ·Î] -i -a -L[geoip¼³Ä¡µð·ºÅ丮ÀÇlib°æ·Î] -I[geoip¼³Ä¡µð·ºÅ丮ÀÇinclude°æ·Î] -lGeoIP -c [mod_geoip.c °æ·Î] ## ¿É¼ÇÀÇ ´ë¼Ò¹®ÀÚ ÁÖÀÇ -lGeoIP = ¼Ò¹®ÀÚ l·Î ½ÃÀÛ
#/usr/local/apache/bin/apxs -i -a -L/usr/local/GeoIP/lib -I/usr/local/GeoIP/include -lGeoIP -c /root/mod_geoip2_1.2.5/mod_geoip.c
4.
¸ðµâÀÌ Á¤»óÀûÀ¸·Î ¼³Ä¡,·Îµå µÇ¾ú´ÂÁö È®ÀÎÇÕ´Ï´Ù.
#ls -al /usr/local/apache/modules/mod_geoip.so
-rwxr-xr-x 1 root root 38179 3¿ù 26 13:16 /usr/local/apache/modules/mod_geoip.so
- httpd.conf ÆÄÀÏÀÇ LoadModule À§Ä¡¿¡ Ãß°¡ µÇ¾ú´ÂÁö È®ÀÎ
LoadModule geoip_module modules/mod_geoip.so
- phpinfo ÆäÀÌÁöÀÇ Apache Environment Á¤º¸¿¡ GEOIP_CONTINENT_CODE, GEOIP_COUNTRY_CODE, GEOIP_COUNTRY_NAME Ç׸ñ È®ÀÎ
5.
httpd.conf¿¡ mod_geoip ¸ðµâÀÇ Àû¿ë ³»¿ëÀ» ¼³Á¤ÇÕ´Ï´Ù.
ƯÁ¤ ±¹°¡ÀÇ Á¢±Ù Â÷´Ü
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/local/GeoIP/share/GeoIP/GeoIP.dat
<Location /home>
SetEnvIf GEOIP_COUNTRY_CODE CN go_out
SetEnvIf GEOIP_COUNTRY_CODE RU go_out
SetEnvIf GEOIP_COUNTRY_CODE TH go_out
<Limit GET POST>
Order allow,deny
Allow from all
Deny from env=go_out
</Limit>
</Location>
</IfModule>
ƯÁ¤ ±¹°¡¿¡¸¸ Á¢±Ù Çã¿ë
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/local/GeoIP/share/GeoIP/GeoIP.dat
<Location /home>
SetEnvIf GEOIP_COUNTRY_CODE KR go_in
<Limit GET POST>
Order Deny,Allow
Deny from all
Allow from env=go_in
</Limit>
</Location>
</IfModule>
[Âü°í]
Cannot load /usr/local/apache/libexec/mod_geoip.so into server: libGeoIP.so.1: cannot open shared object file: No such file or directory
¿¡·¯ ¹ß»ý½Ã
/etc/ld.so.conf ÆÄÀÏ¿¡
/usr/local/GeoIP/lib ¶óÀÎ Ãß°¡ ÈÄ
ldconfig Àû¿ë