|
前言
说到日志分析,大家第一反应可能会想到webalizer,不过我相信你看完这文章后,你将有一个更不错的选择.
Awstats有着我在这里好难说完的特点(有些可能我都不知道),其安装文档也是做得相当完善,只要照上面安装,基本上都可以RUN上!其中文支持也是好完美,更能为你分析来访着是通过GOOGLE ,YAHOO或者是其他搜索入的!其他功能自己看看吧~
唯一美中不足的是:它对硬件的要求好像高了点,但是现在做服务器的我相信那机子的配置也不会差到那里去,据说,一台AMD Athlon 1.2G ,512MB SDRAM分析一个大概500MB 的 Log,所需的时间为3分钟左右.当然我们还可以定时清除或者备份已经分析过或者过时的LOG来减少其大小,以提高分析的速度!
好了,接着我们就来看看利用Awstats来帮我们分析我们的WEB的访问情况!说了这么多,先给大家看看其分析结果的庐山真面目!看了之后保证你们跃跃欲试!
图例:
由于我的网站是本地的,效果不明显,大家可以参考其官方网站的DEMO分析结果參考如下:
http://awstats.sourceforge.net/cgi-bin/awstats.pl
源码下载:
http://awstats.sourceforge.net/
配置步骤:
现在,让我来简单的说说安装步骤(其实其自带的Document写的好详细)
安裝步驟如下
Step 1 : 安装及配置
* Step 1-1将你apache web server的日志格式更改为NCSA combined/XLF/ELF的日志格式.
修改httpd.conf 在找到以下的参数,并确定后面的格式为combined
httpd.conf代码:
修改原来的common为combined
#CustomLog /yourlogpath/yourlogfile common
CustomLog /yourlogpath/yourlogfile combined
* Step 1-2 运行配置脚本,复制相应的文件到相应的目录
解压GZ包
进入该路径下的tools/
我们可以看到configure.pl这个脚本,运行进行配置工作
代码:
[root@intranet awstats-6.1]# cd tools/
[root@intranet tools]# ls –a
awstats_exportlib.pl httpd_conf urlaliasbuilder.pl
awstats_updateall.pl logresolvemerge.pl webmin
awstats_buildstaticpages.pl configure.pl maillogconvert.pl xslt
[root@intranet tools]# ./configure.pl
----- AWStats configure 1.0 (build 1.32) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/home/becks/awstats-6.1
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ? y
-----> Check for web server install
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf ##(输入你httpd.conf文件的路径)
-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
Add 'Alias /awstatsclasses "/home/becks/awstats-6.1/wwwroot/classes/"'
Add 'Alias /awstatscss "/home/becks/awstats-6.1/wwwroot/css/"'
Add 'Alias /awstatsicons "/home/becks/awstats-6.1/wwwroot/icon/"'
Add 'ScriptAlias /awstats/ "/home/becks/awstats-6.1/wwwroot/cgi-bin/"'
Add '<Directory>' directive
AWStats directives added to Apache config file. ##将AWStats参数加入Apache 配置文件
-----> Update model config file '/home/becks/awstats-6.1/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.
-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.ec-base.com ##输入你网站的名称
-----> Create config file '/etc/awstats/awstats.www.ec-base.com.conf'
Config file /etc/awstats/awstats.www.ec-base.com.conf created.
-----> Restart Web server with '/sbin/service httpd restart'
httpd: [ OK ]
httpd: [ OK ]
-----> Add update process inside a scheduler
##提示: configure.pl不支持自动添加任务,你必须手动添加以下命令到任务中,命令作用为更新www.ec-base.com这个我们配置文件的日记分析
/home/becks/awstats-6.1/wwwroot/cgi-bin/awstats.pl -update -config=www.ec-base.com
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/home/becks/awstats-6.1/wwwroot/cgi-bin/awstats.pl -update -config=www.ec-base.com
Or if you have several config files and prefer having only one command:
/home/becks/awstats-6.1/tools/awstats_updateall.pl now
Press ENTER to continue...
A SIMPLE config file has been created: /etc/awstats/awstats.www.ec-base.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.ec-base.com' with command:
> perl awstats.pl -update -config=www.ec-base.com
You can also read your statistics for 'www.ec-base.com' with URL:
> http://localhost/awstats/awstats.pl?config=www.ec-base.com
Press ENTER to finish...
##配置完成,现在COPY相应的文件
[root@intranet tools]# cd ..
[root@intranet awstats-6.1]# cp -rpf wwwroot/cgi-bin/* /var/www/cgi-bin/
[root@intranet wwwroot]# cp -rpf icon/* /var/www/html/
* Step 1-3 修改我们网站的配置文件
代码:
[root@intranet tools]#
vi /etc/awstats/awstats.www.ec-base.com.conf
##按照自己实际情况修改以下参数
LogFile="/var/log/httpd/main/access_log"
SiteDomain="www.ec-base.com" #修改为自己的域名
Lang="auto" ##语言设置为自动即可,会自动根据查看者的语言自行切换
##其他参数默认即可,如果有兴趣进一步研究可以参考Readme
Step 2 : 更新和完成设置
* Step 2-1
第一次分析以及更新我们的日志,必须手动执行以下命令,由于是第一次分析,时间可能较久,这视乎你电脑的性能和日志的大小.
代码:
[root@intranet wwwroot]#/var/www/cgi-bin/awstats.pl -update -config=www.ec-base.com
##結果輸出大概如下 (视个人实际情况)
Lines in file: 20030917
Found 7 dropped records,
Found 520 corrupted records,
Found 0 old records,
Found 2000431 new records.
* Step 2-2
将UPDATE命令加入crontab,以便自动及及时更新.
代码:
[root@intranet wwwroot]#crontab -e
##设置为每7小时更新一次
0 */7 * * * /var/www/cgi-bin/awstats.pl -update -config=www.ec-base.com
Step 3 : 看看我们的分析结果
打开浏览器,浏览以下地址
http://your domain name/cgi-bin/awstats.pl? config=your config flie name
例如依照我刚刚的配置,我的分析结果为
/cgi-bin/awstats.pl?config=www.ec-base.com
OK~~ALL DONE~ 怎么样?没有让你失望吧?IIS使用awstats的例子,请参考
http://www.ec-base.com/weblog/more.asp?name=刺客微软&id=19
Enjoy it!!
刺客微软
2004-6-7 广州 |
|