Linux下日志分析工具Awstats安装笔记

前一段在朋友车东(http://www.chedong.com)的介绍下,得知了awstats这样一个好东西,由于工作一直很忙,好几次想去down下来安装了试试看都没有时间,前几天正巧有点空,去网上down了一个,看看文档,居然一下就安装成功了,一用感觉真的不错!下面把Michael的安装经历和大家分享!

awstats介绍:
Awstats是一个优秀的基于Perl的WEB日志分析工具,可以跨平台,界面友好,分析内容详尽,并且支持多语言的操作界面,是一个发展很快应用很广的日志分析工具。大家可以通过下面的地址访问awstats项目在sourceforge.net上的项目主页。
http://awstats.sourceforge.net

资料准备:awstats
访问地址 http://awstats.sourceforge.net/ 下载最新版的awstats,最新版目前是6.1版,Michael当时下载的是6.0版的,awstats是一个GPL的开源project

安装环境:
Michael安装awstats的环境是在redhat7.3,apache1.3.23,当然awstats也支持freebsd和windows等平台,只要确认您的机器正确安装配置了perl环境,在redhat下面可以使用光盘里面自带的rpm包使用rpm -ihv 命令安装perl包,这里不多说。

安装过程:
1、redhat和apache、perl环境的安装
这些安装不在这里讲述,请参照Michael另外的文章说明。

2、安装awstats
总的来讲,Michael感觉awstats的安装和配置都非常简单
首先下载awstats-6.0.gz到系统任何目录下,进入该目录,执行下面命令
#tar -zxvf ./awstats-6.0.gz
#cp -R ./awstats /usr/local/awstats
将包解压并拷贝到/usr/local/awstas目录下,基本就完成了awstats的安装,然后就是配置

注意,您还需要自己手动创建两个目录,一个是/etc/awstats 和/var/lib/awstats 这两个目录都将在后面的配置中用到,一个用于存放站点日志分析的配置文件,一个用于存放日志数据信息。

3、配置awstats
awstats的配置使用awstats的配置工具 /usr/local/awstats/tools/configure.pl 进行配置,首先用vi打开configure.pl文件,看看第一行有关perl运行环境的配置是否正确,然后运行下面的命令进行配置:
#/usr/local/awstats/tools/configure.pl
基本上整个配置过程很简单,回车和简单填写一些就结束了,configure.pl工具会自动修改您的apache配置,在apache的配置文件httpd.conf文件中自动修改下面信息
CustomLog /yourlogpath/yourlogfile common

CustomLog /yourlogpath/yourlogfile combined
这样的修改将让您的apache在记录日志的时候记录到更多可用于分析的内容,比如来访者的浏览器、来访者的身份(是否为蜘蛛、机器人等)。
同时configure.pl还将自动在httpd.conf文件中添加下面内容:

Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

这将配置awstats可以通过web客户端访问。

另外,configure.pl还将根据安装过程中您的回答(要分析的网站名称)信息,自动生产/etc/awstats/awstats.yourdomain.conf文件,Michael生成的文件是awstats.toplee.conf文件,这个文件几乎不用修改,就可以了,如果您有些特殊的设置,可以自己修改该文件进行配置,Michael的配置文件里面最基本的几行配置内容如下:

LogFile="/var/log/httpd/toplee.com-access_log"
LogType=W
LogFormat=1
LogSeparator=" "
SiteDomain="toplee.com"
HostAliases="toplee www.toplee 127.0.0.1 localhost old.toplee.com"
DNSLookup=2
DirData="/var/lib/awstats"
DirCgi="/awstats"
DirIcons="/awstatsicons"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=2
.....

其他的都是默认设置,不用修改

这样,您就完成了awstas的安装和配置。

4、分析日志
完成awstats的配置以后,要让awstats开始第一次进行您的日志文件的分析,并存放awstats的数据库中,您需要运行下面的命令
#/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=toplee
上面的toplee替换成您/etc/awstats/awstats.yourhost.conf中的yourhost即可

这样,awstats就完成了第一次数据的导入,今后您只需要定期再次运行此命令即可进行增量的更新!
Michael把这个命令加到了crontab中,让他每天凌晨5点运行一次,呵呵,下面是加入到crontab的方法
#crontab -e
输入内容 0 5 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=toplee

至此,您的全部安装和配置完成,重启一下您的apache,在ie里面输入http://www.yourhost.com/awstats/awstats.pl?config=yoursitename&lang=yourlang即可访问!呵呵,好好享受吧!

在这里Michael只是简单的说了一下,中间朋友们有什么问题,欢迎和我交流!

本文可以随意转贴,但是请务必注明出处。

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
No Responses
  1. minecraft says:

    whoah this blog is excellent i love reading your articles.

    Keep up the good work! You understand, many individuals
    are searching round for this info, you can aid them greatly.

  2. minecraft says:

    Usually I do not read post on blogs, but
    I wish to say that this write-up very pressured me to take a look at
    and do so! Your writing taste has been surprised me.

    Thanks, very great post.

  3. wonderful points altogether, you just received a new reader.
    What would you suggest in regards to your put up that you made some days in the past?

    Any sure?

  4. Oh my goodness! Awesome article dude! Many thanks, However I
    am encountering issues with your RSS. I don’t know why I cannot subscribe to it.
    Is there anyone else getting similar RSS problems? Anyone who knows the
    solution can you kindly respond? Thanx!!

  5. Greetings! I know this is kind of off topic but I was wondering which blog platform are you using for this website?
    I’m getting sick and tired of WordPress because I’ve had
    problems with hackers and I’m looking at options for another platform.
    I would be awesome if you could point me in the direction of a good platform.

  6. I know this if off topic but I’m looking into starting my own weblog and was curious
    what all is needed to get set up? I’m assuming having a blog like
    yours would cost a pretty penny? I’m not very web smart so I’m not 100% certain.
    Any recommendations or advice would be greatly appreciated.
    Many thanks

  7. Your style is so unique in comparison to other people I’ve
    read stuff from. Thanks for posting when you have the opportunity,
    Guess I will just book mark this page.

  8. I am no longer positive where you are getting your information, but
    great topic. I needs to spend a while finding out more or figuring
    out more. Thanks for great info I was on the lookout for
    this info for my mission.

  9. quest bars says:

    Good information. Lucky me I recently found your website by chance (stumbleupon).
    I’ve saved as a favorite for later!

  10. Quest Bars says:

    Helpful information. Lucky me I found your website by accident, and I’m stunned why this twist of fate didn’t happened
    earlier! I bookmarked it.

  11. Hello, i read your blog from time to time and i own a similar
    one and i was just wondering if you get a lot of spam feedback?

    If so how do you stop it, any plugin or anything you can suggest?

    I get so much lately it’s driving me crazy so
    any assistance is very much appreciated.

  12. I was suggested this website by my cousin. I am not sure whether this post is written by
    him as no one else know such detailed about my problem.
    You’re amazing! Thanks!

  13. If some one needs expert view concerning blogging after that
    i propose him/her to go to see this blog, Keep up the nice job.

  14. Heya i am for the primary time here. I came across this board and I
    to find It really helpful & it helped me out much.
    I’m hoping to offer one thing again and help others such as you aided me.

  15. Hey! Quick question that’s totally off topic. Do you know how to make your site mobile friendly?
    My weblog looks weird when browsing from my iphone. I’m trying
    to find a template or plugin that might be able to correct this problem.
    If you have any recommendations, please share. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image