RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR
Lighttpd Install mod_geoip For Country / City Level Geo Targeting by NIX Craft on March 29, 2009 · 10 comments· LAST UPDATED June 16, 2010 in CentOS, Debian Linux, FreeBSD Geolocation software is used to get the geographic location of visitor using IP address. You can determine country, organization and guess visitors location. This is useful for a] Fraud detection b] Geo marketing and ad serving c] Target content d] Spam fighting e] And much more. mod_geoip is a Lighttpd module for fast ip/location lookups. In this tutorial you will learn about mod_geoip installation and php server side examples to determine visitors country. mod_geoip uses the MaxMind GeoIP / GeoCity databases, which comes in two version: ◾Free Version: Country and city databases are free with 99.5% accuracy. ◾Paid Version: If you need 99.8% accuracy and other fancy details about IP address use paid version. See this page for Free vs Paid version details. A note about CentOS / RHEL / Fedora Linux users If you are using 3rd party repo (see RPMforge and EPEL repo installations FAQ), you can install binary mod_geoip package as follows and skip directly to configuration part: # yum install lighttpd-mod_geoip Step # 1: Install C API for mod_geoip Type the following command to download and extract MaxMind C API: # cd /tmp # wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz # tar -zxvf GeoIP.tar.gz Install required development package, enter: # yum install zlib-devel Configure, compile and install C API: # cd GeoIP-1.4.6 # ./configure # make # make install Configure GNU ld You need link mod_geoip using C API. You need to configure dynamic linker run time bindings as follows: # cd /etc/ld.so.conf.d/ # vi geoip.conf Append the following configuration: /usr/local/lib Save and close the file. Run ldconfig to activate configuration: # ldconfig Verify that the name of each directory including /usr/local/lib is scanned, and any links that are created: # ldconfig -v | less Sample output: /usr/local/lib: libGeoIPUpdate.so.0 -> libGeoIPUpdate.so.0.0.0 libGeoIP.so.1 -> libGeoIP.so.1.4.6 /usr/lib/mysql: libmysqlclient_r.so.15 -> libmysqlclient_r.so.15.0.0 libmysqlclient.so.15 -> libmysqlclient.so.15.0.0 /usr/lib64/mysql: libmysqlclient_r.so.15 -> libmysqlclient_r.so.15.0.0 libmysqlclient.so.15 -> libmysqlclient.so.15.0.0 /lib: libsepol.so.1 -> libsepol.so.1 libtermcap.so.2 -> libtermcap.so.2.0.8 .... ..... [Output truncated] Step #2: Download lighttpd latest version Type the following command: # cd /tmp # wget http://www.lighttpd.net/download/lighttpd-1.4.22.tar.gz # tar -zxvf lighttpd-1.4.22.tar.gz # cd lighttpd-1.4.22 Step #3: Download mod_geoip patch Type the following command: # cd lighttpd-1.4.22/src # wget http://redmine.lighttpd.net/attachments/download/716/mod_geoip_for_1.4.c -O mod_geoip.c Compile lighttpd with mod_geoip patch Edit Makefile.am and add the following after the last module: lib_LTLIBRARIES += mod_geoip.la mod_geoip_la_SOURCES = mod_geoip.c mod_geoip_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined mod_geoip_la_LIBADD = $(common_libadd) -lGeoIP Save and close the file. Now compile lighttpd as follows: # cd .. # aclocal # automake -a # autoconf # make clean Now you must use --enable-maintainer-mode option: # ./configure --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --with-openssl --enable-maintainer-mode # make # make install Step # 4: Download GeoLite Database (Free version) Type the following command: # wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz # gunzip GeoIP.dat.gz # ls -lh GeoIP.dat Sample output: -rw-r--r-- 1 root root 1.1M Mar 9 21:13 GeoIP.dat Install GeoIP.dat file: # mkdir /usr/local/GeoIP # cp -v GeoIP.dat /usr/local/GeoIP Step # 5: Configure Lighttpd Open your lighttpd.conf file and append the following configuration. First, enable mod_geoip: server.modules += "mod_geoip" Finally, set path to GeoIP.dat file and turn on memory caching for faster lookups: geoip.db-filename = "/usr/local/GeoIP/GeoIP.dat" geoip.memory-cache = "enable" Save and close the file. Finally, restart the lighttpd: # /etc/init.d/lighttpd restart Step # 6: Test your setup mod_geoip will set environment variable such as follows: GEOIP_COUNTRY_CODE GEOIP_COUNTRY_CODE3 GEOIP_COUNTRY_NAME GEOIP_CITY_NAME GEOIP_CITY_POSTAL_CODE GEOIP_CITY_LATITUDE GEOIP_CITY_LONG_LATITUDE GEOIP_CITY_DMA_CODE GEOIP_CITY_AREA_CODE You can use any server side programming language to determine visitors GEO location. Here is a sample php code: What is my IP address - determine or retrieve my IP address Your country : $country"; ?> Another example: Redirecting user to country specific URL References:
2014/07/14 18:42 2014/07/14 18:42
http://zosel.net/trackback/144
ZOSEL:Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
Too much is as bad as too little...!! 자공(子貢)이 공자에게 "사(師:子張의 이름)와 상(商:子夏의 이름)은 어느 쪽이 어집니까?" 하고 묻자, 공자는 "사는 지나치고 상은 미치지 못한다"고 대답하였다. "그럼 사가 낫단 말씀입니까?" 하고 반문하자, 공자는 "지나친 것은 미치지 못한 것과 같다(過猶不及)"고 말하였다.
전체 (209)
리눅스시스템 (92)
윈도우시스템 (16)
프로그램 (7)
네트워크시스템 (7)
최근관심 (1)
«   2020/10   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
  1. Ugg Sito  2015
    Ugg Sito
  2. Ugg Online  2015
    Ugg Online
  3. Ugg Boots Outlet Italia  2015
    Ugg Boots Outlet Italia
  1. 2018/02 (1)
  2. 2017/03 (2)
  3. 2016/12 (2)