webalizer for windows2003安装指南

想监控apache在win下的流量及用户访问量,配了两天的cacti,baidu google来回地切换搜索,最终以失败告终,有图无数据,以下是总结的webalizer for windows2003安装指南。

1、下载webalizer-2.01-10-win32-bin.zip并解压缩至c:\webalizer

2、重命名smaple.conf为webalizer.conf,并增加配置:
LogFile        c:/apache/logs/access.log
#要获取的日志文件
OutputDir     c:/webalizer/usage
#日志输出目录
Incremental yes
ReportTitle Web主机流量分析 
#标题

#配置帮助看这里:http://hi.baidu.com/wangj998/blog/item/b59519f4ba6307ddf3d38531.html

3、输出webalizer
c:\webalizer\>webalizer,此时webalizer目录下将创建usage目录,其内容即为统计数据页面

4、设置能通过WEB访问webalizer
(1).apache添加虚拟目录
Alias /webalizer "c:/webalizer/"
<Directory "c:/webalizer/">; 
Options Indexes MultiViews 
AllowOverride AuthConfig 
   Order Deny,Allow 
   Allow from all 
   Options All 
   AllowOverride All 
</Directory>

(2).创建webalizer\usage目录的访问验证
创建c:\webalizer\.htaccess,内容是:
authtype basic 
authname "受限访问区" 
authuserfile c:/webalizer/.htpasswd #定义密码文件路径
require valid-user

(3).创建密码文件
htpasswd -c c:\webalizer\.htpasswd jxxs #用户名:xiaowan
#输入两次密码:webalizer_xiaowan

(4).在c:\webalizer下新建文件index.php,内容是:
<?
for($i = 1; $i <= 300; $i++ ) print(" "); 
//输出300个字符,使之到达浏览器输出条件才可使用flush将之后新增的数据强制显示到浏览器
echo "统计数据页正在生成,请稍候……";
flush();
//如果不存在当月的统计数据,则调用webalizer.exe生成数据网页
//if (!file_exists("usage/usage_".date(Ym).".html"))
exec("webalizer.exe");//每次都获取新的统计数据
//exec执行完成后才转向至统计首页,在这里若用pclose(popen('start webalizer.exe','r'));"
//则网页不等待webalizer.exe返回就继续往下走,所以转向的时候可能数据网页还没生成完,得到的是空白页,所以要使用exec,强制用户等待。

//header("Location: usage/index.html");//前面已用flush,所以header无效
sleep(1);//让程序"睡"一秒钟,会让你把效果看得更清楚 
echo "<script>location.href='usage/index.html';</script>";//回到统计首页

?>

成功效果图:

webalizer for windows2003安装指南

由于需要PHP后台调用桌面程序,但此桌面程序必须以窗口化形式显示才有效。解决方案总结如下:

//注意:
exec("notepad.exe");
弹出[记事本],记事本在服务器后台运行,且页面一直等待状态。
修改:运行——services.msc——apache2.2——登录——允许服务与桌面交互,则[记事本]弹至桌面,以窗口化形式显示。
pclose(popen('start notepad.exe', 'r')); 
弹出[记事本],页面不等待,直接返回继续执行之后的代码。
帮助文件:http://www.cublog.cn/u/10697/showart.php?id=76986

帮助信息:
windows xp下设置apache目录访问身份验证(目录访问控制)
http://www.chinaunix.net/jh/13/445503.html
Webalizer安裝簡介 
http://www.twvbb.com/vbb/thread/30/45/
在Windows 2000&2003下快速安装Webalizer
http://fun.ccidnet.com/school/system//2003/08/18/134_9233.html
ob_start 用法
http://hi.baidu.com/bing2liuliu/blog/item/84b1020e586831206159f3ff.html

上一篇:移动应用监控运营方案,一站式解决南瓜电影性能监控与用户行为分析需求


下一篇:asp.net 服务器最大连接数TCPIP设定