欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 久久精品蜜芽亚洲国产a | 色网站综合| 日韩欧美精品综合一区二区三区 | 色综合久久综合中文小说 | 国产传媒视频 | 欧美一区二区三区免费不卡 | 久久这里只有精品视频9 | 国产精品一区在线观看你懂的 | 欧美久久网 | 国产孰妇精品AV片国产m3u8 | 免费看污网站 | 草草浮力影视 | 五月天激激婷婷大综合丁香 | 欧美日韩手机在线观看 | 蜜桃视频在线免费播放 | 爱爱无遮挡 | 国产第一页在线视频 | 欧美视频精品 | 在线看免电影网站 | 99精品影视 | 亚洲精品一区二区三区在线 | 免费看黄的视频网站 | 色婷婷综合久久久中字幕精品久久 | 日韩精品区| 啪啪啪毛片 | 日韩欧美在线播放 | 福利免费在线 | 日韩国产第一页 | 亚洲国产成a人v在线 | 一级特黄特黄毛片欧美的 | 毛片基地免费视频a | 天天干天天拍天天射 | 国产 日韩 欧美 在线 | 国产在线精品一区二区 | 日日操夜夜 | 久久99热这里只频精品6中文字幕 | 狠狠躁躁夜夜躁波多野结依 | 国产精品成人在线 | 99久热| 亚洲一区二区福利视频 | 成人18免费入口 |