ADJ網路實驗室
打印

[分享] 超強訪客分析 Awstats -- 連 Windows IIS 也不放過...

超強訪客分析 Awstats -- 連 Windows IIS 也不放過...

記得之前有介紹過 Awstats For Linux 的安裝過程...今天不小心讓偶發現Windows IIS 下也可以做 Multi-Domain 的訪客分析...真是讓人興奮...因為大家都知道..在Windows平台下的軟體...什麼都嘛要錢...最近有找過一些Windows平台下的 Log Analyze...看一看還是沒有 Awstats 來的強...它真的是照福很多 Windows IIS 平台下的管理者囉...

在開始進行之前...你必需先完成 ActivePerl for IIS 的安裝...如果你還沒完成...請先參考這一篇:
讓 Windows IIS下也能跑跨平台的 Perl

接著 Download Awstats:
前往 Awstats 官方網站
在這邊以 Awstats-52.zip 為 Sample...你把壓縮檔解開後...可以看到裡面有個Docs的目錄...裡面寫的很清楚...

在這邊做個簡單的過程描述...

安裝過程 With IIS Server:

* Step 1-1
Configure IIS to log in "Extended W3C log format" (You can still use your own log format but setup is easier if made like suggested). So, for this, start the IIS Snap-in, select the web site and look at its Properties. Choose W3C Extended Log Format, then Properties, then the Tab Extended Properties and uncheck everything under Extended Properties. Once they are all unchecked, check all following fields:
複製內容到剪貼板
代碼:
date
time
c-ip
cs-username
cs-method
cs-uri-stem
sc-status
sc-bytes
cs-version
cs(User-Agent)
cs(Referer)
PS: 以上是要建立W3C擴充記錄檔格式...在擴充內容裡面...這幾個要選一樣的...不能多選...要不然在Run的過程中就會有問題...總共有十一個

To be sure the log format change is effective, you must stop IIS, remove all old log files, restart IIS and go to your homepage. This is an example of records you should get then in the new log file:
2000-07-19 14:14:14 62.161.78.73 - GET / 200 1234 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0) http://www.from.com/from.htm


* Step 1-2
Copy the contents of the uncompressed cgi-bin folder from your hard drive to your server's cgi-bin directory (this includes awstats.pl, awstats.model.conf, and the lang, lib and plugins sub-directories).


* Step 1-3
Move AWStats icon sub-directories and its content into a directory readable by your web server, for example C:\yourwwwroot\icon.

PS:上面兩個步驟因為我要做 Windows版的 Multi-Domain...所以我在D槽建個 awstats的目錄...然後把 wwwroot裡面的cgi-bin 跟 icon 都copy在這邊...
在IIS的部份打算建虛擬目錄的方式...在個別IIS Domain的地方建兩個虛擬目錄...
cgi-bin
icon


* Step 1-4
Copy awstats.model.conf file into a new file named awstats.myvirtualhostname.conf. This new file must be stored in
- same directory than awstats.pl (so cgi-bin)


* Step 1-5
Edit this new config file with your own setup :
複製內容到剪貼板
代碼:
--- Change LogFile value with full path of your web server log file (You can also use a relative path from your awstats.pl directory).
PS: Windows的部份可以改成這樣
LogFile="C:/WINNT/system32/LogFiles/W3SVC1/ex%YY-0%MM-0%DD-0.log"
注意你的Log的路徑

--- Change LogFormat to value "2" (it means "IIS Extended W3C log format").
如 LogFormat=2

--- Change DirIcons parameter to reflect relative path of icon directory.
--- Edit SiteDomain parameter with the main domain name or the intranet web server name used to reach the web site to analyze (Example: www.mydomain.com).
--- You can change other parameters if you want.
--- Set your primary language.
Lang="tw"
Step 2 : Build/Update Statistics

* Step 2-1
The first analyze/update of statistics can be made the first time manually from the command line (the first time, process may be long) :
awstats.pl -config=myvirtualhostname -update

PS:在這邊你可以在cgi-bin裡面寫一個bat的執行檔...如 crontab.bat 內容如下
D:\awstats\cgi-bin\awstats.pl -config=adj -update
這樣你就可以不用每次還要叫出MS-DOS...而且可以利用這個檔案來做排程...

AWStats will read the config file awstats.myvirtualhostname.conf (or if not found, awstats.conf) and create/update its database with all summary information issued from analyzed log file.AWStats database files are saved in directory defined by DirData parameter in config file.
When update is finished, you should get a result like this:
Lines in file: 225730
Found 5 dropped records,
Found 124 corrupted records,
Found 0 old records,
Found 225601 new records.


* Step 2-2
Even if AWStats allows "real-time" statistics with its "update from browser feature" (See next section Read Statistics), you should run an update process from a scheduler (command is same than first process) frequently.

You can add instructions in your crontab (Unix/Linux) or your task scheduler (for Windows), to launch frequently this Awstats update process.
For sites with:
- 10,000 visitors a month Launch AWStats once a day
- 50,000 visitors a month Launch AWStats once every 4 hours
- 250,000 visitors a month Launch AWStats once an hour
- 1,000,000 visitors a month Launch AWStats once an hour
This is ABSOLUTELY necessary to keep good performances.

PS:這個部份是依你的Log來建議你多久做一次排程...至於怎麼做排程??我實在不知道怎麼描述...不知道的人先找資料看看好了..

Step 3 : Read Statistics
好了之後...你可以打開Browser...輸入如下:
http://www.adj.idv.tw/cgi-bin/awstats.pl?config=adj

Online Demo:
Awstats Online

這樣就行啦...當然你還可以在IIS底下..不是有個cgi-bin嗎?按右鍵選內容進去後...目錄安全設定...編輯...匿名存取拿掉...這樣別人要看這個cgi-bin裡面的資料就要打系統裡面有的帳號密碼才看的到囉...這樣是不是有更進一層的防護呢?





TOP


更多好康分享中~~
這是個不錯的技術文章...謝謝大大的分享..有不懂的地方煩請不吝賜教..謝謝


TOP

ARTERY.cn