apache之awstats日誌分析工具的安裝

linux之apahce日誌分析工具awstats


編譯安裝和yum安裝



Awstats是一個非常簡潔而且強大的統計工具。它可以統計您站點的如下信息:

一:訪問量,訪問次數,頁面瀏覽量,點擊數,數據流量等精確到每月、每日、每小時的數據

二:訪問者國家、訪問者IP、操作系統、瀏覽器等

三:Robots/Spiders的統計

四:紡客持續時間

五:對不同Files type 的統計信息

六:Pages-URL的統計

七:其它信息(搜索關鍵字等等)


http://awstats.sourceforge.net/   awstats官方網站


http://www.perl.com/    perl官方網站



[root@localhost awstats]# ls


awstats-7.0.tar.gz     perl-5.16.1.tar.gz


安裝perl                                                              


  Awstats基於Perl的WEB日誌分析工具,網上關於它的介紹還是比較多的,因爲是基於perl開發的,在管在windows還是linux下都需要先安裝perl環境。所以,我們先安裝perl 。其實,還需要一個apache環境,在上一節中已經進行了安裝講解。


[root@localhost awstats]# tar xvfz perl-5.16.1.tar.gz    解壓


[root@localhost awstats]# cd perl-5.16.1    進入目錄


[root@localhost perl-5.16.1# rm -f config.sh Policy.sh


[root@localhost perl-5.16.1]# sh Configure -de


[root@localhost perl-5.16.1]#make    編譯


[root@localhost perl-5.16.1]# make test


[root@localhost perl-5.16.1]# make install    安裝


config.sh Policy.sh   爲以前安裝時的配置文件,新安裝或升級安裝時需要將其刪除。


sh Configure -de   安裝使用默認配置,一般而言將會 ok


make test    執行make命令, 然後make根據test目標規則, 執行規定的操作。


安裝完成後 perl 所在目錄爲 /usr/local/lib/perl5, perl 執行文件在 /usr/local/bin 中。


安裝awstats                                                                          


解壓awstats


[root@localhost awstats]# tar xvfz awstats-6.4.tgz


[root@localhost awstats]# mkdir /etc/awstats


[root@localhost awstats]# mkdir /var/lib/awstats


上面創建的兩個目錄都將在後面的配置中用到,一個用於存放站點日誌分析的配置文件,一個用於存放日誌數據信息。


[root@localhost awstats]# cp -R ./awstats-7.0 /usr/local/  


-R 表示複製目錄及目錄內的所有項目到/usr/local/目錄下


[root@localhost test]# mv  awstats-7.0   awstats     進行一個重命名,便於操作而已。



配置awstats


[root@localhost tools]# pwd


/usr/local/awstats/tools


Awstats的配置有自帶的配置工具awstats_configure.pl ,首先用vi打開configure.pl文件,看看第一行有關perl運行環境的配置是否正確。


[root@localhost tools]# vi awstats_configure.pl


#!/usr/bin/perl


.............


[root@localhost tools]# pwd


/usr/local/awstats/tools


[root@localhost tools]# perl awstats_configure.pl  運行配置文件 或者./awstats_cofigure.pl


Do you want to continue setup from this NON standard directory [yN] ?  你是否安裝非標準目錄【y / n】?

..............


file (required if first install) [y/N] ? 文件(如果需要先安裝)【y / n】?

...........


your web site ,virtual server or profile name: 你的網站服務器名或文件名


>guanli.365fanyi.com   #實例



directory path to store config file(s)  (enter for default):  目錄路徑存儲配置文件(填寫默認值)


> /etc/awstats



然後,兩個回車配置完成。



awstats_configure.pl工具會自動修改您的apache配置,在apache的配置文件httpd.conf文件中自動修改下面信息,如果是yum安裝,會在/etc/httpd/conf.d/下生產awstats.conf文件


[root@localhost conf]# pwd


/usr/local/apache/conf


[root@localhost conf]# vi httpd.conf


awstats_configure.pl自動在httpd.conf文件最底部添加了以下內容:


# Directives to allow use of AWStats as a CGI

#

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#yum安裝時,要將127.0.0.1改成all即可,否則外網訪問不了

</Directory>




  awstats_configure.pl還將根據安裝過程中您的回答(要分析的網站名稱)信息,自動生產 /etc/awstats/awstats.conf文件


[root@localhost awstats]# pwd


/etc/awstats


[root@localhost awstats]# ls


awstats.conf


[root@localhost awstats]# vi awstats.conf  配置下面文件


LogFile="/usr/local/apache/logs/access_log"     改爲apache的日誌文件


這樣就完成了awstats的安裝與配置工作。





分析日誌




[root@localhost cgi-bin]# pwd


/usr/local/awstats/wwwroot/cgi-bin


[root@localhost cgi-bin]# chmod +x  awstats.pl     加可執行權限


[root@localhost cgi-bin]# perl /awstats.pl -update -config=guanli.365fanyi.com      



Create/Update database for config "/etc/awstats/awstats.index.conf" by AWStats version 7.0 (build 1.971)


From data in log file "/usr/local/apache/logs/access_log"...


Phase 1 : First bypass old records, searching new record...


Searching new records from beginning of log file...


Jumped lines in file: 0


Parsed lines in file: 3


Found 0 dropped records,


Found 0 comments,


Found 0 blank records,


Found 3 corrupted records,


Found 0 old records,


Found 0 new qualified records.





在瀏覽器裏輸入:


http://guanli.365fanyi.com/awstats/awstats.pl?config=guanli.365fanyi.com


然後就可以看到生成的日誌報告了

後面的參數太複雜?


可以這樣, 在訪問目錄下:創建一個awstats.html文件

vim awstats.html


<html>

<head>

<meta http-equiv=refresh content="0;url=http://guanli.365fanyi.com/awstats/awstats.pl?config=guanli.365fanyi.com">

</head>

<body></body>

</html>


以後直接就用:http://guanli.365fanyi.com/awstats.html 訪問即可




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章