2008年2月16日 星期六

Awstats 安裝教學

awstats 是一個非常好的網站監控程式

如果有架網站的一定要安裝

不過安裝好後記得設定密碼

以防止駭客鑽漏洞

第一步驟:

先至 http://awstats.sourceforge.net/ 下載 awstats-6.6.tar.gz

第二步驟:

MV指令把 awstats-6.6.tar.gz 放置網頁目錄底下

( SUSE網頁目錄為 /srv/www/htdocs)

(CentOS,Redhat 網頁目錄為 /var/www/html )

#mv awstats-6.6.tar.gz /srv/www/htdocs/

第三步驟:

切換至網頁目錄底下解開 awstats-6.6.tar.gz

#tar zxvf awstats-6.6.tar.gz

解開來後會產生 awstats-6.6 的目錄

第四步驟:

切換至 awstats-6.6 的目錄底下

#cd awstats-6.6

第五步驟:

/usr/local/ 裡建立一個目錄

#mkdir /usr/local/awstats

將解壓縮出來的 tools wwwroot 目錄複製到 /usr/local/awstats

目錄下

#cp –R tools wwwroot /usr/local/awstats

第六步驟:

切換目錄至 /usr/local/awstats

#cd /usr/local/awstats/

第七步驟:

執行 tools 目錄下的 awstats_configure.pl

會出現下面安裝畫面

#./tools/awstats_configure.pl

—– 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 filesapache groupapacheconfhttpd.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/N] ?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

Press ENTER to finish…

第八步驟:

以上步驟完成後,會在/etc/awstats目錄下建立一檔案-

awstats.www.myunix.idv.tw.conf

第九步驟:

建立 /var/lib/awstats 目錄,並給予 777 之權限

#mkdir /var/lib/awstats

#chmod 777 /var/lib/awstats

註:若不給予777權限,將來若設定 AllowToUpdateStatsFromBrowser=1 時,會無法透過Browser來即時更新Report

第十步驟:

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

#

# Directives to allow use of AWStats as a CGI

#

Alias /awstatsclasses “/var/www/html/awstats/wwwroot/classes/”

Alias /awstatscss “/var/www/html/awstats/wwwroot/css/”

Alias /awstatsicons “/var/www/html/awstats/wwwroot/icon/”

ScriptAlias /awstats/ “/var/www/html/awstats/wwwroot/cgi-bin/”

#

# This is to permit URL access to scripts/files in AWStats directory.

#

Options None

AllowOverride None

Order allow,deny

Allow from all

第十一步驟:

設定httpdlog formatcombined,請編輯 httpd.conf,將CustomLog設定為combined

#vi /etc/httpd/conf/httpd.conf

…….

…….

CustomLog logs/access_log combined

…….

PS. SUSE可不用設定

第十二步驟:

設定awstats.www.myunix.idv.tw.conf

#vi /etc/awstats/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” <—–
指定哪些DomainLocal,其餘皆視為External

第十三步驟:

執行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.

第十四步驟:

開啟Browser,輸入 http://www.xxx.xxx/awstats/awstats.pl ,便可

檢視你剛剛所產生的報表了。

第十五步驟:

將十三步驟的指令設定在crontab,讓它定期產生Log Report

2 則留言:

yifang 提到...

你好,請問一下awstats可以與xampp一起跑嘛?
因為我測試結果...它在重新啟動httpd...會失敗,
但是xampp是跑在/opt/lampp/lampp start,不知你是否可在xampp測試過?

匿名 提到...

您好
我安裝之後重啟httpd的時候
出現了
/etc/init.d/httpd restart
正在停止 httpd: [ 確定 ]
正在啟動 httpd:[Mon Apr 29 16:03:21 2013] [warn] The Alias directive in /etc/httpd/conf.d/httpd.conf at line 45 will probably never match because it overlaps an earlier Alias.
[Mon Apr 29 16:03:21 2013] [warn] The Alias directive in /etc/httpd/conf.d/httpd at line 46 will probably never match because it overlaps an earlier Alias.
[Mon Apr 29 16:03:21 2013] [warn] The Alias directive in /etc/httpd/conf.d/httpd at line 47 will probably never match because it overlaps an earlier Alias.
[Mon Apr 29 16:03:21 2013] [warn] The ScriptAlias directive in /etc/httpd/conf.d/httpd at line 48 will probably never match because it overlaps an earlier ScriptAlias.
[ 確定 ]


請問這個是什麼原因呢??