Chinaunix首页 | 论坛 | 博客
  • 博客访问: 301792
  • 博文数量: 63
  • 博客积分: 1997
  • 博客等级: 上尉
  • 技术积分: 690
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-29 11:17
文章分类

全部博文(63)

文章存档

2010年(26)

2009年(37)

我的朋友

分类: LINUX

2010-05-18 11:02:48

一、安装


首先,去下载awstats6.95最新的安装包,解压缩该包,并把它复制到你希望安装的位置,awstats默认让你安装到/usr/local/awstats下面,当然你也可以安装到别的地方,不过这样的话系统会让你确认安装的路径。我们这里以安装到/usr/local/awstats为例。 

另外,awstats要求将http.conf中的CustomLog /yourlogpath/yourlogfile common 改为 

CustomLog /yourlogpath/yourlogfile combined ,我看了一下,我默认的就是combined,可能现在新版本默认的都是这个吧,那就不用改了。 

一切准备妥当以后,我们就开始安装了,先进入/usr/local/awstats/tools里,运行awstats_configure.pl启动安装向导,步骤如下 

[root@demo tools]# ./awstats_configure.pl 



----- AWStats awstats_configure 6.0 (build 1.8) (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



----->; Check for web server install



Enter full config file path of your Web server.


Example: /etc/httpd/httpd.conf


Example: /usr/local/apache/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  [/color]#输入你httpc.conf的路径,对于httpd2系列的一般都在/etc/httpd/conf/这个目录下面,对于这一步我们可以默认,因为到了6.9版本这里就默认道/usr/local/apache/conf/httpd.conf了。


这里将awstats的配置信息直接写入了httpd.conf 

----->; Check and complete web server config file '/etc/httpd/conf/httpd.conf'


  Add ';' directive


  AWStats directives added to Apache config file.



 根据上面的httpd配置,更新了awstats.model.conf的内容,下面的.conf文件都要根据这个生成。 


----->; Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'


  File awstats.model.conf updated.


下面问你是否要创建一个新的配置文件,我们当然要创建了,否则装awstats干什么呀。选y没说的。 

----->; 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[/color]



下面是要生成conf文件的名称了,因为conf文件的名称都是awstats.yourdomainname.conf格式的,所以这里要求你输入你要监测的域名,其实这个域名只是与其他域名相区分的,并不一定非要真实的。我这里输入的是

----->; Define config file name to create


What is the name of your web site or profile analysis ?


Example: 


Example: demo


Your web site, virtual server or profile name:


>; [/color]



下面是让你输入配置文件的路径,直接回车就可以了,当然你也可以自己定义 ,这里要说明一点,如果要更换路径,我们必须修改awstats_configure.pl文件中得路径。 比如我们把/etc/awstats修改为/webserver/awstats

----->; 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):


>; /etc/awstats[/color]



好了,现在就在/etc/awstats下面创建了你定义的配置文件,这里是awstats..conf 

Create config file '/etc/awstats/awstats.'


 Config file /etc/awstats/awstats..conf created.



创建完配置文件以后会自动重启httpd服务。 

/usr/local/apache/bin/apachectl restart'


停止 httpd                                                  [  确定  ]


启动 httpd                                                  [  确定  ]



下面的都是直接回车就可以了 

----->; 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/awstats/wwwroot/cgi-bin/awstats.pl -update -config=


Or if you have several config files and prefer having only one command:


/usr/local/awstats/tools/awstats_updateall.pl now


Press ENTER to continue...


A SIMPLE config file has been created: /etc/awstats/awstats.


You should have a look inside to check and change manually main parameters.


You can then manually update your statistics for '' with command:


>; perl awstats.pl -update -config=


You can also read your statistics for '' with URL:


>; http://localhost/awstats/awstats.pl?config=



Press ENTER to finish...



二、配置


剩下的工作我们就需要手工完成了。 

第一, crontab里手工加进去 

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=,因为这个程序是通过分析日志来进行流量统计的,如果你的日志文件很大的话是很耗系统资源的。还好,我的流量不大,我设定的是每个小时运行一次,你如果服务器比较繁忙的话也可以每天夜里运行一次。当然你也可以手工运行上面的命令来进行更新统计信息。 

第二,conf文件的配置: 


LogFile  

指定你要分析的日志文件,默认是/var/log/httpd/mylog.log,可以根据你的需要调整,如果你要分析httpd的全部日志的就是/var/log/httpd/access_log,我们一般就选这个了。 


LogType  

log类型,默认是web log,不用修改,如果你不是的话就自己照说明改了。 


LogFormat 

log格式,一般情况下如果是apache的话就是1iis就是2,默认不用修改,你也可以照说明自定义,呵呵,我还不太清楚怎么定义。 


LogSeparator 

log中的分隔符,默认不用修改,如果上面的格式是你自定义的话这里也要修改了 


DNSLookup  

默认不用修改 


DirData  

生成的日志分析结果的保存路径,默认是/var/lib/awstats,你如果要使用默认的路径的话,这个目录是需要手工创建的,注意这个路径必须是可读写的。 

下面四项都是在配置时,不用修改。 


DirCgi cgi的路径,这里都是相对于网站根目录的绝对路径 

DirIcons icon的路径 

SiteDomain 域名: 

HostAliases 主机别名 


AllowToUpdateStatsFromBrowser 

下面这项是是否允许从浏览器里更新统计文件,默认是0不允许,如果我们改为1的话,就需要apache的属主用户对/var/lib/awstats目录有读写权限,并对/var/log/httpd目录有读取权限 

  

AllowFullYearView 


这个不用修改默认值。awstats默认是以月为单位进行日志分析,如果我们要分析整年的日志的可以在这里设置,因为分析整年的日志的话可能要消耗很多系统资源。如果你需要对年日志进行分析的话,建议手工启动。 

百万级以上网址建议打开LoadPlugin="hashfiles"

这样最基本的配置就完成了,我们可以通过http:// awstats/awstats.pl?config=来查看统计信息。 


同时安装过程会自动在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/"

Options None
AllowOverride None
Order allow,deny
Allow from all
 


重启Apache:

/usr/local/apache/bin/apachectl restart


统计旧的主机日志:

mkdir -p /webserver/awstats
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config= -update -Logfile=/backup/access_20100329.log 

如果产生得页面出现乱码,我们可以加如下参数-lang=cn
定时统计所有主机日志:

0 * * * * /usr/local/awstats/tools/awstats_updateall.pl now -configdir=/backup/awstats > /dev/null 2>&1


测试:

阅读(4898) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~