天天看點

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