免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8492 | 回复: 8
打印 上一主题 下一主题

[Web] 完整安装配置awstats的方法(V0.5版) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-11-18 12:18 |只看该作者 |倒序浏览
作者:苏小勇
http://www.bestunix.net


关键词: awstats 日志分析

说明:下面的完全安装步骤几乎完全是按照文档一步步来的,并没什么新意,但我在网上搜了一下,这样的操作说明还算是独一无二的了,谨以此文献给跟我一样菜的菜鸟们。本文还不太成熟,有什么问题欢迎大家反馈。转载请保留作者联系信息,谢谢。

首先,去http://awstats.sourceforge.net/下载awstats的安装包,解压缩该包,并把它复制到你希望安装的位置,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启动安装向导,步骤如下
  1. [root@demo tools]# ./awstats_configure.pl

  2. ----- AWStats awstats_configure 1.0 (build 1.3) (c) Laurent Destailleur -----
  3. This tool will help you to configure AWStats to analyze statistics for
  4. one web server. You can try to use it to let it do all that is possible
  5. in AWStats setup, however following the step by step manual setup
  6. documentation (docs/index.html) is often a better idea. Above all if:
  7. - You are not an administrator user,
  8. - You want to analyze downloaded log files without web server,
  9. - You want to analyze mail or ftp log files instead of web log files,
  10. - You need to analyze load balanced servers log files,
  11. - You want to 'understand' all possible ways to use AWStats...
  12. Read the AWStats documentation (docs/index.html).

  13. ----->; Running OS detected: Linux, BSD or Unix

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

  15. Enter full config file path of your Web server.
  16. Example: /etc/httpd/httpd.conf
  17. Example: /usr/local/apache2/conf/httpd.conf
  18. Example: c:\Program files\apache group\apache\conf\httpd.conf
  19. Config file path ('none' to skip web server setup):
  20. >; /etc/httpd/conf/httpd.conf  [/color]#输入你httpc.conf的路径,对于httpd2系列的一般都在/etc/httpd/conf/这个目录下面
复制代码

这里将awstats的配置信息直接写入了httpd.conf
  1. ----->; Check and complete web server config file '/etc/httpd/conf/httpd.conf'
  2.   Add '<Directory>;' directive
  3.   AWStats directives added to Apache config file.
复制代码


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

  1. ----->; Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
  2.   File awstats.model.conf updated.
复制代码

下面问你是否要创建一个新的配置文件,我们当然要创建了,否则装awstats干什么呀。选y没说的。
  1. ----->; Need to create a new config file ?
  2. Do you want me to build a new AWStats config/profile
  3. file (required if first install) [y/N] ? y[/color]
复制代码


下面是要生成conf文件的名称了,因为conf文件的名称都是awstats.yourdomainname.conf格式的,所以这里要求你输入你要监测的域名,其实这个域名只是与其他域名相区分的,并不一定非要真实的。我这里输入的是www.bestunix.net
  1. ----->; Define config file name to create
  2. What is the name of your web site or profile analysis ?
  3. Example: www.mysite.com
  4. Example: demo
  5. Your web site, virtual server or profile name:
  6. >; www.bestunix.net[/color]
复制代码


下面是让你输入配置文件的路径,直接回车就可以了,当然你也可以自己定义
  1. ----->; Define config file path
  2. In which directory do you plan to store your config file(s) ?
  3. Default: /etc/awstats
  4. Directory path to store config file(s) (Enter for default):
  5. >; /etc/awstats[/color]
复制代码


好了,现在就在/etc/awstats下面创建了你定义的配置文件,这里是awstats.www.bestunix.net.conf
  1. ----->; Create config file '/etc/awstats/awstats.www.bestunix.net.conf'
  2. Config file /etc/awstats/awstats.www.bestunix.net.conf created.
复制代码


创建完配置文件以后会自动重启httpd服务。
  1. ----->; Restart Web server with '/sbin/service httpd restart'
  2. 停止 httpd                                                  [  确定  ]
  3. 启动 httpd                                                  [  确定  ]
复制代码


下面的都是直接回车就可以了
  1. ----->; Add update process inside a scheduler
  2. Sorry, configure.pl does not support automatic add to cron yet.
  3. You can do it manually by adding the following command to your cron:
  4. /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.bestunix.net
  5. Or if you have several config files and prefer having only one command:
  6. /usr/local/awstats/tools/awstats_updateall.pl now
  7. Press ENTER to continue...
  8. A SIMPLE config file has been created: /etc/awstats/awstats.www.bestunix.net.conf
  9. You should have a look inside to check and change manually main parameters.
  10. You can then manually update your statistics for 'www.bestunix.net' with command:
  11. >; perl awstats.pl -update -config=www.bestunix.net
  12. You can also read your statistics for 'www.bestunix.net' with URL:
  13. >; http://localhost/awstats/awstats.pl?config=www.bestunix.net

  14. Press ENTER to finish...
复制代码


剩下的工作我们就需要手工完成了。
第一,        在crontab里手工加进去
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.bestunix.net,因为这个程序是通过分析日志来进行流量统计的,如果你的日志文件很大的话是很耗系统资源的。还好,我的流量不大,我设定的是每个小时运行一次,你如果服务器比较繁忙的话也可以每天夜里运行一次。当然你也可以手工运行上面的命令来进行更新统计信息。
第二,conf文件的配置:

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

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

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

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

DNSLookup
默认不用修改

DirData
生成的日志分析结果的保存路径,默认是/var/lib/awstats,你如果要使用默认的路径的话,这个目录是需要手工创建的,注意这个路径必须是可读写的。
下面四项都是在配置时,不用修改。

DirCgi cgi的路径,这里都是相对于网站根目录的绝对路径
DirIcons icon的路径
SiteDomain 域名:www.bestunix.net
HostAliases 主机别名

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

AllowFullYearView

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

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



常见问题:

问题一,在第一次进行日志分析时候就出错了
  1. [root@demo conf.d]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.bestunix.net
  2. Error: AWStats database directory defined in config file by 'DirData' parameter (/var/lib/awstats) does not exist or is not writable.
  3. Setup ('/etc/awstats/awstats.www.bestunix.net.conf' file, web server or permissions) may be wrong.
  4. Check config file, permissions and AWStats documentation (in 'docs' directory).
复制代码

这个是因为在/etc/awstats/awstats.www.bestunix.net.conf中DirData中定义的目录启动apache的用户没有写得权限,更改目录或更改权限都可以解决。
问题二,出来的页面里所有的流量统计都是空的。
同样是/etc/awstats/awstats.www.bestunix.net.conf的问题,在这个文件里有一行
LogFile="/var/log/httpd/mylog.log"
我们一般情况下把这个路径改为”/var/log/apache/access.log”就可以了,如果你设了很多虚拟主机,每个主机都配置了不同的log的话,在这里指定你要统计的那个主机的log文件就可以了。
问题三,浏览页面时提示没有权限,出现403错误,如下
  1. Forbidden
  2. You don't have permission to access /awstats/awstats.pl on this server.
  3. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request
复制代码

因为/usr/local/awstats这个目录默认属主是root,其他用户没有执行的权限,我把这个目录的权限改为755就可以了。但是理论上应该只需要改wwwroot的权限就可以了,很奇怪。

更改默认的index文件,默认是index.html,我们可以根据自己的需要修改,比如我改为了
  1. DefaultFile="index.html index.php index.htm"
复制代码

论坛徽章:
0
2 [报告]
发表于 2004-12-20 12:24 |只看该作者

完整安装配置awstats的方法(V0.5版)

好,支持!

论坛徽章:
0
3 [报告]
发表于 2005-04-22 18:12 |只看该作者

完整安装配置awstats的方法(V0.5版)

问题三,浏览页面时提示没有权限,出现403错误,如下
代码:
Forbidden
You don't have permission to access /awstats/awstats.pl on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request

因为/usr/local/awstats这个目录默认属主是root,其他用户没有执行的权限,我把这个目录的权限改为755就可以了。但是理论上应该只需要改wwwroot的权限就可以了,很奇怪。


我把awstats包括子目录和文件都改成755还是不行,还是这个提示

论坛徽章:
0
4 [报告]
发表于 2007-10-10 08:04 |只看该作者
我的把awstats整个目录设置成755就可以了啊

论坛徽章:
0
5 [报告]
发表于 2007-10-10 09:48 |只看该作者
好文章,是原创吗?
转贴到我的论坛上去

论坛徽章:
0
6 [报告]
发表于 2008-08-04 20:56 |只看该作者

请教问题,

如果你设了很多虚拟主机,每个主机都配置了不同的log的话,在这里指定你要统计的那个主机的log文件就可以了。


你好!我按照你的 前步都装好了。就是到 虚拟主机这块卡住了。能具体说下吗?比如我有 www.home.com 这个虚拟主机改在哪 设置啊?是在虚拟主机设置里,还是还在awstats的配置文件里啊?

论坛徽章:
0
7 [报告]
发表于 2008-08-05 20:26 |只看该作者
原帖由 gron 于 2008-8-4 20:56 发表
如果你设了很多虚拟主机,每个主机都配置了不同的log的话,在这里指定你要统计的那个主机的log文件就可以了。


你好!我按照你的 前步都装好了。就是到 虚拟主机这块卡住了。能具体说下吗?比如我有 www.h ...

http://bbs.chinaunix.net/viewthr ... p;highlight=awstats

论坛徽章:
0
8 [报告]
发表于 2008-08-19 08:51 |只看该作者

论坛徽章:
0
9 [报告]
发表于 2008-08-20 16:47 |只看该作者

回复 #1 sxybit 的帖子

你好朋友:

我统计比较大一点的日志,大约600M的日志是出现下面提示:

From data in log file "/opt/nfs2/svrlog/case0801-09/all/case0801.log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Flush history file on disk (unique url reach flush limit of 5000)
Flush history file on disk (unique url reach flush limit of 5000)
Flush history file on disk (unique url reach flush limit of 5000)

哪位朋友 遇到过这个问题啊?请赐教!我的QQ  158863748 MSN: arong521@hotmail.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP