歡迎您光臨本站 註冊首頁

使用awstats對apache日誌進行監測

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

使用awstats對apache日誌進行監測

我把我自己做的拿出來與大家分享,發現cu 裡面對這個工具的介紹比較少,可能是比較傻瓜把。
1AWStats 是一個免費的強大而有個性的工具,帶來先進的網路,流量,FTP或郵件伺服器統計圖. 它能分析日誌文件來自從各大伺服器工具 ,如 Apache日誌檔案  (NCSA combined or common), WebStar, IIS (W3C),Proxy、Wap、流量伺服器、郵件伺服器和一些FTP伺服器.  
AWStats官方網址:http://awstats.sourceforge.net/

從官方網站下載AWStats,目前最新版本是6.7

首先修改apache的日誌格式為combined(這個是awstats默認的日誌格式),重新啟動apache 伺服器使之生效。
tar zxvf  awstats-6.7.tar.gz
mv awstats-6.7 /usr/local/awstats

cd /usr/local/awstats

perl tool/awstats_configure.pl

Do you want to continue setup from this NON standard directory ? y   

//輸入你的web server的配置文件路徑 使用none跳過設置
Config file path (』none』 to skip web server setup):     
> none

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

Your web site, virtual server or profile name:
> www.test.com

//直接回車 使用默認路徑 /etc/awstats
Directory path to store config file(s) (Enter for default):      
> /etc/awstats

vi /etc/awstats/awstats.www.test.com.conf

//修改日誌路徑

LogFile=」/var/log/www/10235.%YYYY-24%MM-24%DD」

//指定日誌類型 W - web log  M - mail log  F - ftp log  S - streaming log
    LogType=W

//指定日誌格式 1 - Apache combined logs  2 - IIS
    LogFormat=1

//日誌分析結果輸出目錄 確保該目錄有寫許可權
    DirData=」/var/www/awstats/test/dirdata」

cp -R icon /var/www/html/test(主要用於顯示圖片)

cp -R css /var/www/html/test

//執行命令

/usr/bin/perl  /usr/local/awststs/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com

/usr/bin/perl  /usr/local/awststs/wwwroot/cgi-bin/awstats.pl -config=www.test.com -output -staticlinks > /var/www/html/test/index.html

說明,由於我的apache禁止cgi, 所以我沒有直接用cgi來查看,只是把它轉為靜態的html頁面來查看(不需要修改apache的配置文件)。

把上面兩個加入到cron中,執行時間斷可以根據自己的需求來定。我的是半個小時一次。

安全設置:

對test目錄加入訪問密碼與用戶修改apache配置文件httpd.conf

<Directory "/var/www/html/test">

Options Indexes FollowSymLinks

AllowOverride AuthConfig //把none修改為AuthConfig

Order allow,deny
Allow from all

</Directory>

重新啟動apache伺服器,使之配置生效。

cd /var/www/html/test

vi .htaccess

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require user rbowen

保存。

/usr/local/apache/bin/htpasswd -c /usr/local/apache/passwd/passwords rbowen
New password: mypassword
Re-type new password: mypassword
Adding password for user rbowen

現在你就可以通過用戶名和密碼訪問test/頁面了,注意:Basic方式密碼是用過明文傳輸,如果想通過加密的方式傳輸密碼,請用Digest方式。詳細情況請閱讀apache相關文檔。

[ 本帖最後由 fsm11 於 2007-8-3 12:00 編輯 ]
《解決方案》

是原創么?轉到我的論壇上行不行?
或者您自己發到我的論壇上:http://www.webiase.com

[ 本帖最後由 xpdz 於 2007-8-1 15:15 編輯 ]
《解決方案》

是不是還要用cronolog做日誌格式的改變啊?
《解決方案》

原帖由 xpdz 於 2007-8-1 15:12 發表 http://bbs.chinaunix.net/images/common/back.gif
是原創么?轉到我的論壇上行不行?
或者您自己發到我的論壇上:http://www.webiase.com
是的,你可以轉到你的論壇上去,只要說明來處就可以。
《解決方案》

原帖由 jordanfang 於 2007-8-2 00:05 發表 http://bbs.chinaunix.net/images/common/back.gif
是不是還要用cronolog做日誌格式的改變啊?
對需要改變日誌格式,默認的是combined格式。

[火星人 ] 使用awstats對apache日誌進行監測已經有649次圍觀

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