Jan 14

[原]Awstats日志分析工具 雨

linuxing , 12:51 , 基础知识 » 性能评估 , 评论(0) , 引用(0) , 阅读(27933) , Via 本站原创 | |
 一直想找个工具分析一下有些什么人来参观我的blog,经过朋友推荐,决定使用AWStats。
 官方网站:http://awstats.sourceforge.net
 安装平台:红旗 DC Server 5.0 for x86

一、安装
 安装还是比较简单的,先下载,然后编译即可:
cd /usr/local/src
wget http://internap.dl.sourceforge.net/sourceforge/awstats/awstats-6.5.tar.gz
cd awstats-6.5
make
make install

 安装结束提示信息有:
引用
Please add the following to your apache config, and restart.
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/www/awstats/classes/"
Alias /awstatscss "/usr/local/www/awstats/css/"
Alias /awstatsicons "/usr/local/www/awstats/icons/"
ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#

   Options None
   AllowOverride None
   Order allow,deny
   Allow from all

 也就是他要你修改apache的配置文件,加入上面的几句。这里可以不用手动增加,后面用命令也可以。
 AWStats软件主要文件安装在 /usr/local/awstats 目录下。
二、准备
 要使用AWStats,必须搞清楚几个地方:
1、你使用的Apache配置文件在那里?
 红旗DC Server 5.0默认是放在/etc/httpd/conf/httpd.conf
2、根据要求修改日志记录方式,记录它的文件和路径
 因为AWStats是靠分析apache的日志文件来生成数据的,所以必须修改日志的记录方式为它所使用的方式。
 在httpd.conf文件中加入:
引用
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined

 修改apache的Log方式:
引用
CustomLog logs/access_log combined

 如果你使用的是虚拟主机方式,则可以修改虚拟主机设置中的CustomLog,如:
引用

ServerName www.test.com
DocumentRoot /usr/local/www/test
CustomLog /var/log/test_access_log combined
ErrorLog /var/log/test_error_log

 最后重启apache。
※注意,如果你以前有旧格式的日志文件,最好删掉它,等待自动生成新格式的日志文件
三、生成配置文件
 使用AWStats自带的awstats_configure.pl命令:
cd /usr/local/www/awstats/tools/
./awstats_configure.pl

根据提示提供apache的配置文件路径;提供配置文件的名字;其他默认即可。
引用
-----> 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 filesapache groupapacheconfhttpd.conf
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
 AWStats directives already present.

-----> Update model config file '/usr/local/awstats/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:
> test

-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>

-----> Create config file '/etc/awstats/awstats.rfgz.conf'
Config file /etc/awstats/awstats.test.conf created.

-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/www/awstats/wwwroot/cgi-bin/awstats.pl -update -config=rfgz
Or if you have several config files and prefer having only one command:
/usr/local/www/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...


A SIMPLE config file has been created: /etc/awstats/awstats.rfgz.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'test' with command:
> perl awstats.pl -update -config=test
You can also read your statistics for 'test' with URL:
> http://localhost/awstats/awstats.pl?config=test

Press ENTER to finish...

 生成的配置文件在/etc/awstats下,名字类似awstats.test.conf。通常我们可以再进行修改:
引用
LogFile="/var/log/test_access_log"
DirData="/var/lib/awstats"

四、生成AWStats数据,并查看
 使用下面的命令让AWStats分析日志:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=test

 若是有多个配置文件,则可以执行:
/usr/local/awstats/tools/awstats_updateall.pl now -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl now

 生成的数据库默认放在:/var/lib/awstats/下。
 访问地址:
引用
http://ip/awstats/awstats.pl?config=test/

 示例图:
点击在新窗口中浏览此图片
五、使用crontab定期更新记录
# crontab -l
0 */8 * * * /usr/local/awstats/tools/awstats_updateall.pl -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl now


※2006-01-14 第一次编写
Tags: , ,
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]