欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Ubuntu下安裝GeoIP

系統 4656 0

Ubuntu下安裝GeoIP | 簡單.生活

Ubuntu下安裝GeoIP

Category : 工作學習 / Tags : , , , / Date : 2011.09.10 / 485 views /

什么是GeoIP ?

所謂GeoIP,就是通過來訪者的IP, 定位他的經緯度,國家/地區,省市,甚至街道等位置信息的一個數據庫。GeoIP有兩個版本,一個免費版,一個收費版本。收費版本的準確率和數據更好一些。

GeoIP如何使用?

GeoIP支持多種語言調用,這里我們以PHP為例。 ?

方法一

通過APT安裝PHP對GeoIP的支持模塊

                  1

                
                  
                    apt-get
                  
                  
                    install
                  
                   php5-geoip libgeoip1
                

下載GeoIP數據庫

                  1
2

                
                  
                    wget
                  
                  
                    -N
                  
                  
                    -q
                  
                   http:
                  
                    //
                  
                  geolite.maxmind.com
                  
                    /
                  
                  download
                  
                    /
                  
                  geoip
                  
                    /
                  
                  database
                  
                    /
                  
                  GeoLiteCity.dat.gz

                  
                    wget
                  
                  
                    -N
                  
                  
                    -q
                  
                   http:
                  
                    //
                  
                  geolite.maxmind.com
                  
                    /
                  
                  download
                  
                    /
                  
                  geoip
                  
                    /
                  
                  database
                  
                    /
                  
                  GeoLiteCountry
                  
                    /
                  
                  GeoIP.dat.gz
                

解壓數據庫

                  1

                
                  
                    gzip
                  
                  
                    -d
                  
                   GeoLiteCity.dat.gz
                

復制GeoIP數據庫到數據目錄

                  1

                
                  
                    cp
                  
                   GeoLiteCity.dat 
                  
                    /
                  
                  usr
                  
                    /
                  
                  share
                  
                    /
                  
                  GeoIP
                  
                    /
                  
                  GeoIPCity.dat
                

注:這里的路徑和編譯GeoIP C API所使用的–with-dbdir參數有關。

測試GeoIP

重啟Apaceh

                  1

                
                  
                    /
                  
                  etc
                  
                    /
                  
                  init.d
                  
                    /
                  
                  apache2 restart
                

在Web目錄下新建一個測試的PHP文件,這里以geoip.php為例:

                  1
2
3
4
5
6

                
                  
                    vi
                  
                  
                    /
                  
                  var
                  
                    /
                  
                  www
                  
                    /
                  
                  geoip.php
?

                  
                    <
                  
                  ?php

                  
                    $country
                  
                   = geoip_record_by_name
                  
                    (
                  
                  
                    '61.128.128.68'
                  
                  
                    )
                  
                  ; 
                  
                    if
                  
                  
                    (
                  
                  
                    $country
                  
                  
                    )
                  
                  
                    {
                  
                  
                    echo
                  
                  
                    'This host is located in: '
                  
                  ; print_r
                  
                    (
                  
                  
                    $country
                  
                  
                    )
                  
                  ; 
                  
                    }
                  
                  
print geoip_db_filename
                  
                    (
                  
                  GEOIP_COUNTRY_EDITION
                  
                    )
                  
                  ;
?
                  
                    >
                  
                

訪問這個文件,如出現下面類似信息,則表示成功了。

                  1
2

                
                  This host is located 
                  
                    in
                  
                  : Array 
                  
                    (
                  
                  
                    [
                  
                  continent_code
                  
                    ]
                  
                   =
                  
                    >
                  
                   AS 
                  
                    [
                  
                  country_code
                  
                    ]
                  
                   =
                  
                    >
                  
                   CN 
                  
                    [
                  
                  country_code3
                  
                    ]
                  
                   =
                  
                    >
                  
                   CHN 
                  
                    [
                  
                  country_name
                  
                    ]
                  
                   =
                  
                    >
                  
                   China 
                  
                    [
                  
                  region
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    33
                  
                  
                    [
                  
                  city
                  
                    ]
                  
                   =
                  
                    >
                  
                   Chongqing

                  
                    [
                  
                  postal_code
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    [
                  
                  latitude
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    29.562799453735
                  
                  
                    [
                  
                  longitude
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    106.55280303955
                  
                  
                    [
                  
                  dma_code
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    0
                  
                  
                    [
                  
                  area_code
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    0
                  
                  
                    )
                  
                

方法二

通過源碼方式安裝

安裝GeoIP C API

                  1
2
3
4
5
6

                
                  
                    wget
                  
                   http:
                  
                    //
                  
                  geolite.maxmind.com
                  
                    /
                  
                  download
                  
                    /
                  
                  geoip
                  
                    /
                  
                  api
                  
                    /
                  
                  c
                  
                    /
                  
                  GeoIP.tar.gz

                  
                    tar
                  
                   xvzf GeoIP.tar.gz

                  
                    cd
                  
                   GeoIP-1.4.8
.
                  
                    /
                  
                  configure

                  
                    make
                  
                  
                    make
                  
                  
                    install
                  
                

通過pecl安裝geoip模塊。

                  1

                
                  pecl 
                  
                    install
                  
                   geoip
                

啟用GeoIP PHP模塊

                  1
2

                
                  
                    vi
                  
                  
                    /
                  
                  etc
                  
                    /
                  
                  php5
                  
                    /
                  
                  conf.d
                  
                    /
                  
                  geoip.ini

                  
                    extension
                  
                  =geoip.so
                

復制GeoIP數據庫到數據目錄

                  1

                
                  
                    cp
                  
                   GeoLiteCity.dat 
                  
                    /
                  
                  usr
                  
                    /
                  
                  local
                  
                    /
                  
                  share
                  
                    /
                  
                  GeoIP
                  
                    /
                  
                  GeoIPCity.dat
                

注:這里的路徑和編譯GeoIP C API所使用的–with-dbdir參數有關。

測試GeoIP

重啟Apaceh

                  1

                
                  
                    /
                  
                  etc
                  
                    /
                  
                  init.d
                  
                    /
                  
                  apache2 restart
                

在Web目錄下新建一個測試的PHP文件,這里以geoip.php為例:

                  1
2
3
4
5
6

                
                  
                    vi
                  
                  
                    /
                  
                  var
                  
                    /
                  
                  www
                  
                    /
                  
                  geoip.php
?

                  
                    <
                  
                  ?php

                  
                    $country
                  
                   = geoip_record_by_name
                  
                    (
                  
                  
                    '61.128.128.68'
                  
                  
                    )
                  
                  ; 
                  
                    if
                  
                  
                    (
                  
                  
                    $country
                  
                  
                    )
                  
                  
                    {
                  
                  
                    echo
                  
                  
                    'This host is located in: '
                  
                  ; print_r
                  
                    (
                  
                  
                    $country
                  
                  
                    )
                  
                  ; 
                  
                    }
                  
                  
print geoip_db_filename
                  
                    (
                  
                  GEOIP_COUNTRY_EDITION
                  
                    )
                  
                  ;
?
                  
                    >
                  
                

訪問這個文件,如出現下面類似信息,則表示成功了。

                  1
2

                
                  This host is located 
                  
                    in
                  
                  : Array 
                  
                    (
                  
                  
                    [
                  
                  continent_code
                  
                    ]
                  
                   =
                  
                    >
                  
                   AS 
                  
                    [
                  
                  country_code
                  
                    ]
                  
                   =
                  
                    >
                  
                   CN 
                  
                    [
                  
                  country_code3
                  
                    ]
                  
                   =
                  
                    >
                  
                   CHN 
                  
                    [
                  
                  country_name
                  
                    ]
                  
                   =
                  
                    >
                  
                   China 
                  
                    [
                  
                  region
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    33
                  
                  
                    [
                  
                  city
                  
                    ]
                  
                   =
                  
                    >
                  
                   Chongqing

                  
                    [
                  
                  postal_code
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    [
                  
                  latitude
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    29.562799453735
                  
                  
                    [
                  
                  longitude
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    106.55280303955
                  
                  
                    [
                  
                  dma_code
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    0
                  
                  
                    [
                  
                  area_code
                  
                    ]
                  
                   =
                  
                    >
                  
                  
                    0
                  
                  
                    )
                  
                

一些編譯中常見的錯誤

如果你的系統中的libtool中的版本低于2.2.6b,可能會出現以下錯誤提示:

                  1
2
3

                
                  libtool: Version mismatch error. This is libtool 2.2.6 Debian-2.2.6a-
                  
                    4
                  
                  , but the
libtool: definition of this LT_INIT comes from libtool 2.2.6b.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.6 Debian-2.2.6a-
                  
                    4
                  
                

解決方法:先執行以下語句后,再重新編譯。

                  1
2
3
4

                
                  autoreconf 
                  
                    --force
                  
                  
.
                  
                    /
                  
                  configure

                  
                    make
                  
                  
                    make
                  
                  
                    install
                  
                

參考文檔

http://www.google.com

http://blog.chinaunix.net/space.php?uid=642374&do=blog&cuid=1944521

http://stackoverflow.com/questions/3096989/libtool-version-mismatch-error

Ubuntu下安裝GeoIP


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日韩免费视频播放 | 日韩欧美一区二区在线观看 | 日本不卡在线 | 久久娱乐网 | 在线91| 欧美亚洲国产精品第一页 | 国产一区二区欧美 | 亚洲综合色视频在线观看 | 亚洲精品456人成在线 | 久热香蕉精品视频在线播放 | 国产精品免费av | 久九九精品免费视频 | 午夜国产精品视频 | 亚洲精品成A人在线观看拍拍拍 | 天天视频在线播放观看视频 | 成人免费毛片aaaaaa片 | 涩色婷婷狠狠第四四房社区奇米 | 亚洲国产日韩在线观频 | 日韩做A爰片久久毛片A片 | 欧美日韩在线免费观看 | 欧美区在线播放 | 成人在线免费视频观看 | 日本免费不卡一区二区 | 亚洲天天更新 | 久久精品亚洲欧美日韩精品中文字幕 | 欧美日日射 | 国产在线精品一区 | 久久精品国产精品青草图片 | 亚洲综合一二三区 | 超碰一区 | 中文字幕第页 | 九九热视频在线观看 | 99热这里有免费国产精品 | 精品久久久久久久久久久久久久 | bt日韩 | 99亚洲精品 | 欧美成人xxxx | 国产精品大片在线观看 | a在线观看免费 | 日韩免费黄色片 | 国产精品免费播放 |