AWStats配置与应用详解_第1页
AWStats配置与应用详解_第2页
AWStats配置与应用详解_第3页
AWStats配置与应用详解_第4页
AWStats配置与应用详解_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

原创 AWStats 配置 Apache Windows IIS 的日志分析工具 2009年08月20日 星期四 12 09 RHEL 5 3 简介简介 奇码科技的美国空间是带有详细的统计流量工具 awstats AWStats 是一套免费基于 Perl 的网站日志分析工具 这个工具界面较为友好 执行速度快 扩展功能众多 在国外空间使 用 apache 服务器的 AWStats 是当之无愧的首选 Awstats 是一个免费非常简洁而且强大有个性的统计工具统计工具 它可以统计您站点的如下信息 访问量 访问次数 页面浏览量 点击数 数据流量等 精确到每月 每日 每小时的数据 访问者国家 访问者 IP Robots Spiders 的统计 纺客持续时间 对不同 Files type 的统计信息 Pages URL 的统计 访客操作系统浏览器等信息 其它信息 搜索关键字等等 AWStats 是一个免费的强大而有个性的工具 带来先进的网络流量 FTP 或邮件服务器统 计图 本日志分析器作为 CGI 或从命令行在数个图形网页中显示你日志中包含的所有可 能信息 它利用一部分档案资料就能经常很快地处理大量日志档案 它能分析日志文件来 自从各大服务器工具 如 Apache 日志档案 NCSA combined XLF ELF log format or common CLF log format WebStar IIS W3C 的日志格式 及许多其他网站 Proxy 代 理服务器 Wap 流量服务器 邮件服务器和一些 FTP 服务器 看一看这个比较表在最著名统计工具 AWStats Analog Webalizer 之间有何特点和不同 的想法 AWStats 是一个在 GNU 通用公共许可证下发行的免费软件 你可以看看这个许可证图表 而知道你可以 不可以做 由于 AWStats 工程来自网上信息 但也作为 CGI 它可以与允许进入 Perl CGI 与日志的 大型网站主办提供商一起工作 下载下载 安装安装 打开页面 wget 也可下载 wget rpm ivh awstats 6 9 1 noarch rpm Preparing 100 1 awstats 100 AWStats 6 9 Laurent Destailleur AWStats files have been installed in usr local awstats If first install follow instructions in documentation usr local awstats docs index html to setup AWStats in 3 steps Step 1 Install and Setup with awstats configure pl or manually Step 2 Build Update Statistics with awstats pl Step 3 Read Statistics whereis awstats awstats usr etc awstats usr local awstats 配置配置 awstats awstats 要求将 http conf 中的 CustomLog yourlogpath yourlogfile common 改为 CustomLog yourlogpath yourlogfile combined 我看了一下 我默认的就是 combined 可能现在新版 本默认的都是这个吧 那就不用改了 再进入 usr local awstats tools 里 运行 awstats configure pl 启动安装向导 cd usr local awstats tools awstats configure pl AWStats awstats configure 1 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 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 的路径 对于 httpd2 系列的一般都在 etc httpd conf 这个目录下面 这 里将 awstats 的配置信息直接写入了 httpd conf Check and complete web server config file etc httpd conf httpd conf Add Alias awstatsclasses usr local awstats wwwroot classes Add Alias awstatscss usr local awstats wwwroot css Add Alias awstatsicons usr local awstats wwwroot icon Add ScriptAlias awstats usr local awstats wwwroot cgi bin Add directive AWStats directives added to Apache config file 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 Example demo Your web site virtual server or profile name 下面是要生成 conf 文件的名称了 因为 conf 文件的名称都是 awstats yourdomainname conf 格式的 所以这里要求你输入你要监测的域名 其实这个域名 只是与其他域名相区分的 并不一定非要真实的 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 conf Error Failed to open usr local awstats wwwroot cgi bin awstats model conf for read 那是因为该路径找不到 awstats model conf 文件可以修改 而该文件所在的目录是 usr local www awstats cgi bin 既然程序只读固定的路径 那就按照它要读取的路径进行相 关设置 然后重新配置一次 cp usr etc awstats awstats model conf usr local awstats wwwroot cgi bin awstats configure pl Create config file etc awstats conf Config file etc awstats 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 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 conf 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 更新数据 usr local awstats wwwroot cgi bin awstats pl update config Error AWStats database directory defined in config file by DirData parameter var lib awstats does not exist or is not writable Setup etc awstats conf file web server or permissions may be wrong Check config file permissions and AWStats documentation in docs directory 对于 var lib awstats 目录没有写入权限造成的 chmod 777 var lib awstats chmod cannot access var lib awstats No such file or directory mkdir var lib awstats chmod 777 var lib awstats 更新数据 usr local awstats wwwroot cgi bin awstats pl update config Create Update database for config etc awstats conf by AWStats version 6 9 build 1 925 From data in log file var log httpd mylog log Error Couldn t open server log file var log httpd mylog log No such file or directory Setup etc awstats conf file web server or permissions may be wrong Check config file permissions and AWStats documentation in docs directory 日志路径错位造成的 vi etc awstats conf 将 LogFile var log httpd mylog log 改成 LogFile var log httpd access log 更新数据 usr local awstats wwwroot cgi bin awstats pl update config Create Update database for config etc awstats conf by AWStats version 6 9 build 1 925 From data in log file var log httpd access 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 Jumped lines in file 0 Parsed lines in file 8 Found 0 dropped records Found 0 corrupted records Found 0 old records Found 8 new qualified records cp usr local awstats wwwroot cgi bin awstats model conf etc awstats common conf vi etc awstats conf Include common conf LogFile var log httpd mylog log LogFile var log httpd access log YYYY 24 MM 24 DD 24 YYYY 24 MM 24 DD 24是指用24小时前的年月日日志文件名 如 access log 20061206 LogFile gzip d SiteDomain HostAliases 127 0 0 1 localhost DefaultFile index html DirData var lib awstats DirData home cgi bin awstats data 添加定时分析指令 crontab e 20 1 usr local awstats wwwroot cgi bin awstats pl update config 配置配置 apache vi etc httpd conf httpd conf 281 DocumentRoot var www html 282 DocumentRoot usr local awstats wwwroot 这里将 awstats 的配置信息直接写入了 httpd conf 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 对要分析的虚拟主机 将 CustomLog logs access xxx log common 中的 common 改成 combined 从新启动 apache service httpd restart 用浏览器访问 http server awstats awstats pl config mysite http 218 254 awstats awstats pl config The server encountered an internal error or misconfiguration and was unable to complete your request 当你的 web 程序出现上述错误后 很有可能是文件的权限设置的不对 linux 下文件单个 文件需要设置为755 当你设置的是777就会这样 SELinux 有提示 根据 SELinux 的提示 更改配置 chcon t httpd sys content t usr local awstats wwwroot cgi bin awstats pl 用浏览器再次访问 http 218 241 143 254 awstats awstats pl config 把图标等文件目录复制到 WEB 的 HTML 文件发布目录下 例如 home apache htdocs 下发布更多的批量更新脚本等在 tools 目录下 可以一并放到 cgi bin awstats 目录下升级 国内主要搜索引擎和蜘蛛定义 安装 GeoIP 的应用库 C 解包 编译安装 perl MCPAN e install Geo IP 或者使用纯 Perl 包 perl MCPAN e install Geo IP PurePerl 下载 GeoIP GeoIPCityLite 包 解包并部署到 awstats 目录下 wget wget 将缺省 awstats model conf 命名成 common conf 修改其中的一些配置选项 LoadPlugin decodeutfkeys LoadPlugin geoip GEOIP STANDARD home apache LoadPlugin geoip city maxmind GEOIP STANDARD home apache bin awstats GeoLiteCity dat 创建 awstats 下创建 data 目录用于统计数据输出 缺省的统计输出是按月汇总的 对于日 志非常大的最好选择按天统计输出 并修改 awstats pl 设置 LIMITFLUSH 加10倍 LIMITFLUSH 50000 Nb of records in data arrays after how we need to flush data on disk 可以有效提高统计的速度 减少磁盘 IO 并避免按月汇总数据导致的统计文件过大 按照一下样例设置配置文件 Include common conf LogFile home apache logs access log YYYY 24 MM 24 DD 24 SiteDomain HostAliases DefaultFile index html DirData home apache cgi bin awstats data 内容摘要 AWStats 的使用简介和配置一些改进说明 很高兴看到在 AWStats 6 3 版本开始 中文用 户基本上已经只需要将配置文件中将 LoadPlugin decodeutfkeys 启用基本上就没有什么中 文搜索引擎的统计问题了 目前增加了多个国内主要搜索引擎厂商 包含了针对国内主要搜 索引擎和蜘蛛定义的补丁 解包后覆盖 lib 目录下的原程序目录即可 其中也包含了本站的 样例配置文件 日志统计系统在站点的用户行为分析中扮演了重要的角色 尤其是对于来自搜索引擎的关键 词访问统计 是很有效的用户行为分析数据来源 随着互联网多年的发展 WEB 日志统计 工具已经越来越成熟 功能也越来越丰富 其中有很多是开放源代码的 AWStats 就是其 中非常优秀的一款 AWStats Advanced Web Statistics AWStats 是在 Sourceforge 上发展很快的一个基于 Perl 的 WEB 日志分析工具 相对于另 外一个非常优秀的开放源代码的日志分析工具 Webalizer AWStats 的优势在于 1 界面友好 可以根据浏览器直接调用相应语言界面 有简体中文版 参考输出样例 2 基于 Perl 并且很好的解决了跨平台问题 系统本身可以运行在 GNU Linux 上或 Windows 上 安装了 ActivePerl 后 分析的日志直接支持 Apache 格式 combined 和 IIS 格 式 需要修改 Webalizer 虽然也有 Windows 平台版 但目前已经缺乏维护 AWStats 完全可以实现用一套系统完成对自身站点不同 WEB 服务器 GNU Linux Apache 和 Windows IIS 服务器的统一统计 3 效率比较高 AWStats 输出统计项目比 Webalizer 丰富了很多 速度仍可以达到 Webalizer 的1 3左右 对于一个日访问量百万级的站点 这个速度都是足够的 4 配置 定制方便 系统提供了足够灵活但缺省也很合理的配置规则 需要修改的缺省配置 不超过3 4项就可以开始运行 而且修改和扩展的插件还是 比较多的 5 AWStats 的设计者是面向精确的 Human visits 设计的 因此很多搜索引擎的机器人访问 都被过滤掉了 因此有可能比其他日志统计工具统计的数字要低 来自公司内部的访问也可 以通过 IP 过滤 设置过滤掉 6 提供了很多扩展的参数统计功能 使用 ExtraXXXX 系列配置生成针对具体应用的参数 分析会对产品分析非常有用 更多与其他工具 Webalizer analog 的比较请参考 AWStats 安装备忘 AWStats 的运行模式是这样的 1 分析日志 运行后将这样的日志统计结果归档到一个 AWStats 的数据库 纯文本 里 2 然后是输出 分两种形式 一种是通过 cgi 程序读取统计结果数据库输出 一种是运行后台脚本将输出导出成静态文件 以下是2个针对单个站点日志统计例子 一个是在 GNU Linux 上通过 CGI 方式的输出 一个是在 Windows 2000 上的基于静态页面的导出 下载 安装 下载安装包后 GNU Linux tar zxf awstats version tgz awstats 的脚本和静态文件缺省都在 wwwroot 目录下 将 cgi bin 目录下的文件都部署 awstats pl 程序到 home apache cgi bin awstats 下 mv awstats version wwwroot cgi bin path to apache cgi bin awstats 把图标等文件目录复制到 WEB 的 HTML 文件发布目录下 home apache htdocs 下发布 更多的批量更新脚本等在 tools 目录下 可以一并放到 cgi bin awstats 目录下 Windows 2000 按照后台脚本模式运行 直接解包 然后移动到 D AWStats 目录下 把图标 icon 目录复制到 IIS 的发布目录下 inetpub icon 数据源日志格式和按天的截断规则 1 对于 Apache 日志格式好设置 设置成 combined 格式即可 日志截断麻烦一点 需要 安装 cronolog 工具 将日志设置成按天截断 CustomLog usr local sbin cronolog path to apache logs access log Y m d combined 比如 logs access log 20030326 日志是压缩格式 可以使用 gzip d Registering installation for awstats 6 6 1 1 这里是让你输入配置文件的路径 直接回车会执行默认的 当然你也可以自己定义 剩下的工作我们就需要手工完成了 第一 在 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 的话就是1 iis 就是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 默认是以月为单位进行日志分析 如果我们要分析整年的日 志的可以在这里设置 因为分析整年的日志的话可能要消耗很多系统资源 如果你需要对年 日志进行分析的话 建议手工启动 这样最基本的配置就完成了 我们可以通过 来查看统计信息 常见问题 usr local awstats wwwroot cgi bin awstats pl update config Error AWStats database directory defined in config file by DirData parameter var lib awstats does not exist or is not writable Setup etc awstats conf file web server or permissions may be wrong Check config file permissions and AWStats documentation in docs directory 这个是因为在 etc awstats conf 中 DirData 中定义的目录启动 apache 的用户没有写得权限 更改目录或更改权限都可以解决 问题二 出来的页面里所有的流量统计都是空的 同样是 etc awstats conf 的问题 在这个文件里有一行 LogFile var log httpd mylog log 我们一般情况下把这个路径改为 var log apache access log 就可以了 如果你设了很多虚拟 主机 每个主机都配置了不同的 log 的话 在这里指定你要统计的那个主机的 log 文件就可 以了 问题三 浏览页面时提示没有权限 出现403错误 给上 wwwroot 目录权限755就 OK 了 注 默认的 awstats 目录结构里并没有 wwwroot 可以自己加上去 附 其它说明 按天统计 perl awstats pl config www my update databasebreak day bin awstats pl config databasebreak day day 22 month 12 year 20 08 不统计指定 IP 的访问量 SkipHosts x x x x 不统计指定 URL SkipFiles badpage php page php param x REGEX excludedirectory 数据源日志格式和按天的截断规则 对于 Apache 日志格式好设置 设置成 combined 格式即可 日志截断麻烦一点 需要安装 cronolog 工具 将日志设置成按天截断 CustomLog usr local sbin cronolog path to apache logs access log Y m d combined 比如 logs access log 20061126 日志是压缩格式 可以使用 gzip d install Net XWhois 修改 usr local etc awstats conf 取消下面这行的注释 启用此插件 LoadPlugin hostinfo 安装 decodeutfkeys 解决搜索搜索关键词乱码问题 不管是 utf8 gb2312 perl MCPAN e shell cpan install URI Escape 修改 usr local etc awstats conf 取消下面这行的注释 启用此插件 LoadPlugin decodeutfkeys 更新日志 usr local awstats wwwroot cgi bin awstats pl config update lang cn 仅统计分析指定 URL OnlyFiles REGEX abc abc URL 中包括 abc abc 如 abc abc xxxx Update statistics when I use a load balancing system that splits my logs LogFile pathto logresolvemerge pl file log 在配置文件中指定 logresolvemerge pl file1 log file2 log filen log newfiletoprocess log 先用工具把所有 LOG 合并 再配置 LogFile 多台缓存服务器的日志合并处理 多服务器的日志合并统计 如果调用月度速度很慢的时候 可以考虑把输出文件静态化 path awstats tools awstats buildstaticpages pl update config lang cn dir path data www mgr1 test awstats awstatsprog path app tools awstats wwwroot cgi bin awstats pl DatabaseBreak month month mm 使用月份的两位数 builddate 04 02 01 以某一日期为文件名输出页面 提高些处理速度 unique url reach flush limit of 5000 在 awstats pl 中修改 默认值是5000 如果内存较大 可以适当加大 比如50000 参考 AWStats 开源项目 Webalizer 开源项目 http www webalizer org 日志分析工具 商业日志统计 分析工具 al 多站点的日志合并 日志统计对于分析搜索引擎对站点的影响具 有非常重要的意义 AWStats 插件说明 感谢 孙国光 常见问题 问题一 在第一次进行日志分析时候就出错了 root demo conf d usr local awstats wwwroot cgi bin awstats pl update config Error AWStats database directory defined in config file by DirData parameter var lib awstats does not exist or is not writable Setup etc awstats conf file web server or permissions may be wrong Check config file permissions and AWStats documentation in docs directory 这个是因为在 etc awstats conf 中 DirData 中定义的目录启动 apache 的用户没有写得权限 更改目录或更改权限都可以解决 问题二 出来的页面里所有的流量统计都是空的 同样是 etc awstats conf 的问题 在这个文件里有一行 LogFile var log httpd mylog log 我们一般情况下把这个路径改为 var log apache access log 就可以了 如果你设了很多虚拟 主机 每个主机都配置了不同的 log 的话 在这里指定你要统计的那个主机的 log 文件就 可以了 问题三 浏览页面时提示没有权限 出现 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 就可

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论