搭建AWStats日誌分析系統(內附awstats軟件包)

概述

AWStats是免費的一個非常強大的日誌分析工具的Apache日誌文件。 從apache分析日誌後,它以易於理解的圖形格式顯示它們。 它是高級Web統計的縮寫,它可以在命令行界面或CGI上運行。

 

功能

它可以統計您站點的如下信息:

一:訪問量,訪問次數,頁面瀏覽量,點擊數,數據流量等

二:精確到每月、每日、每小時的數據

三:訪問者國家

四:訪問者IP

五:Robots/Spiders的統計

六:訪客持續時間

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

八:Pages-URL的統計

九:訪客操作系統瀏覽器等信息

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

 

實驗環境

系統環境:centos 6.5
服務器IP地址:192.168.100.10
yum掛載目錄:/mnt/sr0

awstats軟件包掛載到linux系統中

awstats軟件包 百度網盤鏈接:https://pan.baidu.com/s/1WeO74SxuKhmEm3k4U02cNg 密碼:czog

 

實驗目的

1.學會部署awstats分析系統

2. 優化網頁地址

3.設置awstats網頁訪問認證

 

實驗步驟

1.安裝awstats軟件包

[root@localhost ~]# mount.cifs //192.168.100.8/ww /abc          /掛載軟件包到linux裏面

 [root@localhost ~]# tar zxvf awstats-7.6.tar.gz -C /opt/ > /dev/null             /解壓軟件到opt目錄下

 [root@localhost ~]# mv /opt/awstats-7.6  /usr/local/awstats            /移動軟件到/usr/local/目錄下

 

2.爲要統計的站點建立配置文件

[root@localhost ~]# cd /usr/local/awstats/tools           /切換目錄

[root@localhost tools]# chmod +x awstats_configure.pl     /賦予腳本執行權限

  [root@localhost tools]# ./awstats_configure.pl       /執行腳本

 

(1)指定httpd主配置文件路徑

----- AWStats awstats_configure 1.0 (build 20140126) (c) Laurent Destailleur

This tool will help you to configure AWStats to analyze statistics for
                        ……(省略部分內容)

-----> 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配置文件路徑

 

(2)設置日誌類型

 ----> Check and complete web server config file '/usr/local/httpd/conf/httpd.conf'
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).

Do you want me to setup Apache to write 'combined' log files [y/N] ? y  /將日誌格式轉換成combined,顯示更爲詳細

 

(3)爲指定web創建配置文件

-----> 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/N] ? y    /是否需要創建AWStats的配置文件,選擇"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.benet.com  /綁定網站域名,虛擬主機名或者自定義配置名,可以同時支持多個站點進行觀測。
我的是www.benet.com

-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):

> /定義配置文件路徑,直接點擊回車默認是在/etc/awstats目錄下

-----> Create config file '/etc/awstats/awstats.www.bt.com.conf'
Config file /etc/awstats/awstats.www.bt.com.conf created.

-----> Restart Web server with '/sbin/service httpd restart'

-----> 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=www.bt.com
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.www.bt.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.bt.com' with command:
\> perl awstats.pl -update -config=www.bt.com
You can also read your statistics for 'www.bt.com' with URL:

> http://localhost/awstats/awstats.pl?config=www.benet.com   /注意訪問awstats的URL
Press ENTER to finish…    /點擊回車結束

 

3.搭建httpd服務

[root@localhost ~]# yum -y install httpd
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf       /修改主配置文件

 

ServerName www.benet.com:80     /域名
Listen 192.168.100.10:80              /監聽地址

 

[root@Iocal ~]# service httpd start     /啓動httpd服務


 

4.搭建DNS服務器

(1)安裝bind軟件包

[root@localhost ~]# cd /mnt/sr0/Packages/
[root@localhost Packages]# rpm -ivh bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm

 

(2) 修改主配置文件named.conf

[root@localhost ~]# vim /etc/named.conf

15

16

(3) 創建並修改DNS正向解析文件

[root@localhost ~]# cd /var/named/
[root@localhost named]# cp -p named.localhost benet.com.zone  /將模板文件改爲正向解析文件進行修改
[root@localhost ~]# vim /var/named/benet.com.zone  /修改正向解析文件

14

(4) 啓動dns服務

[root@localhost ~]# service named start  

 

5.修改站點統計配置文件

[root@localhost named]# vim /etc/awstats/awstats.www.benet.com.conf

1

11

 

[root@localhost named]# mkdir /var/lib/awstats     /創建指定目錄

 

6.執行日誌分析  

[root@localhost named]# service iptables stop    /關閉防火牆

[root@localhost named]# setenforce 0                 /關閉安全性

3

 

7.手動更新網頁數據

12

9

 

8.設置週期性計劃任務表

[root@localhost tools]# crontab –e        /設置週期性任務計劃表

6
[root@localhost tools]# service crond start     /啓動週期性任務服務

 

9.網頁地址優化

[root@localhost tools]# cd /var/www/html
[root@localhost html]# vim awb.html    

 

<html>
<head>
   <meta http-equiv=refresh content="0;url=
http://www.benet.com/awstats/awstats.pl?config=www.benet.com">
</head>
<body></body>
</html>

 

10.查看優化效果,使用http://www.benet.com/awb.html 訪問

13

 

11.設置awstats網頁訪問認證

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf

7

 

12.驗證

8

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