欢迎访问www.showerlee.com, 您的支持就是我前进的动力.

Centos6.3下awstats+GeoIP实现查看网站访问归属地

showerlee 2013-08-29 13:25 AWSTATS 阅读 (7,277) 抢沙发

awstats是一款国外开源的网站PV流量监控软件,能够通过获取apache或nginx日志信息,将日志内有用的信息整合到html页面显示,由于解析日志的内容非常细致,所以圈里很多都拿此作为网站PV数据参考。

之前介绍了如何在apache平台上搭载awstats,今天研究了一下午,终于将GeoIP插件整合到awstats中,实现IP反向解析归属地功能。

系统环境:  centos6.3 x64

awstats:   awstats-7.1.1

GeoIP:     GeoIP-1.4.8

Geo-IP:    Geo-IP-1.27

Geo-IPfree:Geo-IPfree-0.2

一.部署环境:

1.关闭iptables和SELINUX

# service iptables stop

# setenforce 0

# vi /etc/sysconfig/selinux

---------------

SELINUX=disabled

---------------

2.安装依赖包

# yum install perl-devel libtool -y

使libtool生效

# aclocal

3.安装配置awstats传送门:http://www.showerlee.com/archives/757

二.安装配置GeoIP插件:

1.这里需要编译安装3个GeoIP编译包,这3个包互相关联,必须逐一安装:

# wget http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.8.tar.gz

# tar zxf GeoIP-1.4.8.tar.gz

# cd GeoIP-1.4.8

# ./configure --prefix=/usr/local/GeoIP

# make && make install

由于笔者编译GeoIP时自定义了安装路径,所以这里需要加载关联GeoIP模块库

# echo '/usr/local/GeoIP/lib' >> /etc/ld.so.conf

# /sbin/ldconfig /etc/ld.so.conf

# wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz

# tar zxf Geo-IP-1.27.tar.gz

# cd Geo-IP-1.27

关联GeoIP库文件:

# perl Makefile.PL LIBS='-L/usr/local/GeoIP/lib' INC='-I/usr/local/GeoIP/include'

# make && make install

# wget http://search.cpan.org/CPAN/authors/id/G/GM/GMPASSOS/Geo-IPfree-0.2.tar.gz

# tar -zxvf Geo-IPfree-0.2.tar.gz

# cd Geo-IPfree-0.2

# perl Makefile.PL

# make && make install

2.下载MaxMind免费提供的GeoIP和GeoIPCityLite数据包:

# cd /etc/awstats/

# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

# gzip -d GeoLiteCity.dat.gz

# gzip -d GeoIP.dat.gz

3.配置awstats加载归属地数据包

# vi awstats.www.abc.com.cn.conf

末行添加如下内容:

-----------------------

LoadPlugin="geoip GEOIP_STANDARD /etc/awstats/GeoIP.dat"

LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /etc/awstats/GeoLiteCity.dat"

-----------------------

重新刷新页面,如图:

1

-------大功告成---------

正文部分到此结束
版权声明:除非注明,本文由(showerlee)原创,转载请保留文章出处!
本文链接:http://www.showerlee.com/archives/762

继续浏览:AWSTATSGeoIP

还没有评论,快来抢沙发!

发表评论

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif