歡迎您光臨本站 註冊首頁

教你如何建立awstats 日誌分析系統

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

教你如何建立awstats 日誌分析系統

【安裝AWStats】

(1)請先從官方網址 ( http://awstats.sourceforge.net/ ) 下載AWStats ( http://prdownloads.sourceforge.net/awstats/awstats-6.1.tgz )

(2)解壓縮 awstats-6.1.tgz

(3)將解壓縮出來的 tools 及 wwwroot 目錄複製到 /usr/local/awstats 目錄下

(4)切換目錄至 /usr/local/awstats 目錄

(5)執行 tools 目錄下的 configure.pl

程式碼:
tools/configure.pl


(6)設定config檔
----- AWStats configure 1.0 (build 1.32) (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的絕對路徑

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
  AWStats directives already present.

-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
  File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) ?y

-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.myunix.idv.tw <-------- 輸入你所要建立的WebSite name

-----> 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=wwww.myunix.idv.tw
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/awstats.wwww.myunix.idv.tw.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'wwww.myunix.idv.tw' with command:
> perl awstats.pl -update -config=wwww.myunix.idv.tw
You can also read your statistics for 'wwww.myunix.idv.tw' with URL:
> http://localhost/awstats/awstats.pl?config=wwww.myunix.idv.tw

Press ENTER to finish...

(7)以上步驟完成後,會在/etc/awstats目錄下建立一檔案- awstats.www.myunix.idv.tw.conf

(8)建立 /var/lib/awstats 目錄,並給予 777 之權限
註:若不給予777權限,將來若設定 AllowToUpdateStatsFromBrowser=1 時,會無法透過Browser來即時更新Report

(9)設定 httpd.conf,檢查在httpd.conf中是否有以下設定,如果沒有的話,請自行加入,並且重新啟動httpd服務

程式碼:
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path "/usr/local/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>


【分析 Apache Log】
適用於:Apache 1.3.x、Apache 2.0.x

(1)設定httpd的log format為combined,請編輯 httpd.conf,將CustomLog設定為combined

程式碼:
CustomLog logs/access_log combined


註:如果你有多個Virtual Domain的話,建議分成不同的access log,以利分析

Log格式範例如下:
172.16.46.96 - - "GET /forum/templates/subSilver/images/spacer.gif HTTP/1.1" 304 0 "http://it.myunix.idv.tw/forum/viewtopic.php?t=274" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"


(2)設定awstats.www.myunix.idv.tw.conf

程式碼:
LogFile="/var/log/httpd/access_log"  <----請指定你apache log file的絕對路徑及log名稱
LogType=W <---- W代表分析類型為web log files
LogFormat=1 <---- 1代表Apache or Lotus Notes/Domino native combined log format
SiteDomain="www.myunix.idv.tw" <----指定定從log檔中過濾符合SiteDomain的記錄(不同的Virtual Domain就須指定為不同的SiteDomain)
HostAliases="myunix.idv.tw www.myunix.idv.tw" <-----指定哪些Domain為Local,其餘皆視為External


設定完畢,請存檔

(3)執行awstats.pl,記得指定設定檔時,不要輸入設定檔名前面的 awstats. 及 .conf

程式碼:
# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.myunix.idv.tw -update


如果出現以下訊息,就代表執行成功

Update for config "/etc/awstats/awstats.www.myunix.idv.tw.conf"
With data in log file "/var/log/httpd/access_log.1"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 4311)
Jumped lines in file: 4311
Found 4311 already parsed records.
Parsed lines in file: 0
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 0 new qualified records.


(4)開啟Browser,輸入 http://www.xxx.xxx/awstats/awstats.pl?config=www.myunix.idv.tw ,便可檢視你剛剛所產生的報表了。

Demo Site

(5)記得將步驟(3)的指令設定在crontab,讓它定期產生Log Report

[ 本帖最後由 simonfirst 於 2009-2-19 16:59 編輯 ]
《解決方案》

回復 #1 simonfirst 的帖子

一些基礎的分析都是從這裡開始的
《解決方案》

謝謝樓主共享文檔

[火星人 ] 教你如何建立awstats 日誌分析系統已經有477次圍觀

http://coctec.com/docs/service/show-post-24192.html