linux安裝AWStats業務數據分析工具

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  運行配置文件

複製代碼
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: 你的網站服務器名或文件名

>demo

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

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

> /etc/awstats

...........

然後,兩個回車配置完成。
複製代碼

 

 

awstats_configure.pl工具會自動修改您的apache配置,在apache的配置文件httpd.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

</
Directory
>
複製代碼

 

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

[root@localhost awstats]# pwd

/etc/awstats

[root@localhost awstats]# ls

awstats.index.conf

[root@localhost awstats]# vi awstats.index.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=demo      

複製代碼
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://localhost/awstats/awstats.pl?config=demo

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

 

有可能與到下面的錯誤提示,不管你有沒有遇到,反正我是遇到了!:

複製代碼
Not Found


The requested URL /awastats/awastats.pl was not found on this server.


----------------------------------------------------------------------------- 

Apache/2.2.3 (CentOS) Server at 192.168.0.105 Port 80

複製代碼

 

上面的錯誤一直沒找到原因,於是,找了另一種辦法來訪問日誌文件。

[root@localhost cgi-bin]# pwd

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

[root@localhost cgi-bin]# perl awstats.pl -update -config=demo -output -staticlinks >/var/www/html/awastats.html

這樣我們把日誌文件保存到apache 服務器下面,名爲awastats.html

在瀏覽器裏輸入:

http://localhost/awstats.html

一樣可以訪問日誌文件噢!

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