[DreamH 3]网站访问统计awstats

dreamhost将logs目录固化在用户根目录下了, 分域名存储,目录结构如下

logs
|– fanlix.com
| |– http -> http.5xxxxx9
| `– http.5xxxxx9
| |– access.log
| |– access.log.0 -> access.log.2007-07-31
| |– access.log.2007-07-28.gz
| |– access.log.2007-07-29.gz
| |– access.log.2007-07-30
| |– access.log.2007-07-31
| |– analog
| | |– fanlix.com.2007-07.cache
| | |– fanlix.com.2007-07.cache.yesterday
| | |– fanlix.com.daily.conf
| | |– fanlix.com.longterm.cache
| | |– fanlix.com.longterm.cache.yesterday
| | |– fanlix.com.longterm.conf
| | `– fanlix.com.monthly.conf
| |– analog_success.txt
| |– error.log
| |– error.log.0 -> error.log.2007-07-31
| |– error.log.2007-07-28.gz
| |– error.log.2007-07-29.gz
| |– error.log.2007-07-30
| |– error.log.2007-07-31
| |– hits
| | |– bandwidth.20070728
| | |– bandwidth.20070729
| | |– bandwidth.20070730
| | |– hits.20070730
| | `– ref.20070730
| `– html
| |– daily
| |– daily.html -> /home/fanlix/logs/fanlix.com/http.5xxxxx9/html/inactive_report.html
| |– inactive_report.html
| |– index.html -> /home/fanlix/logs/fanlix.com/http.5xxxxx9/html/monthly/2007-07/index.html
| |– longterm
| | |– code.png
| | |– index.html
| | `– size.png
| |– longterm.html -> /home/fanlix/logs/fanlix.com/http.5xxxxx9/html/longterm/index.html
| |– main.html
| |– monthly
| | `– 2007-07
| | |– browrep.png
| | |– browsum.png
| | `– type.png
| `– monthly.html -> /home/fanlix/logs/fanlix.com/http.5xxxxx9/html/monthly/2007-07/index.html

可见不只是apache日志那么简单,还有简单的统计分析。
可是google了一下也没找到访问的方式,DH自己的页面里也只是说道可以下载Funnel Web来自己进行数据统计,并没说这些文件的何去何从。

不论怎么统计,似乎不能比awstats再厉害了吧。
以前用过awstats,还曾经通过上面记录的一个可疑ip,一路反查出一个访问我blog的同学来。
Let’s yEsTerday onCe mOre.

首先到Panel -> Status -> Site Statistics 将logs的保存选择为恰当时效,比如360 Day (hoho~)
默认是保存3日,超过3日的会占用自己的空间,200G,随便用吧。
后面的edit点进去可以设置生成日志统计和邮件提醒的细节。
难怪刚才找不到logs目录的访问方式,原来那些统计文件是发邮件用到的。将logs目录开放是很危险的。

DH默认是没有装awstats的:

$ aptitude search awstats
p awstats – powerful and featureful web server log analyzer

自己动手:

$ wget ‘http://jaist.dl.sourceforge.net/sourceforge/awstats/awstats-6.7.tar.gz’
$ tar -zxvf awstats-6.7.tar.gz
$ mv awstats-6.7 ~/websoft/awstats

————–中间这个方法有些麻烦,可以跳过看下个分割线—————–
然后到panel设置访问路径
Domains -> Remap Sub-Dir
将 http://www.fanlix.com/awstats 映射到 /home/fanlix/websoft/awstats/wwwroot
(有句话提示映射到他人目录没有cgi执行权限, 也就是说可以映射了哦…. shell可是无法访问他人目录的)

cd cgi-bin/
cp awstats.model.conf awstats.fanlix.com.conf
vi awstats.fanlix.com.conf

1500行的配置文件,在结尾加上必要的配置即可:

LogFile=”/home/fanlix/logs/fanlix.com/http/access.log”
SiteDomain=”fanlix.com”
HostAliases=”www.fanlix.com”
DNSLookup=0
DirData=”/home/fanlix/websoft/awstats/awdata”
DirIcons=”icon”
SaveDatabaseFilesWithPermissionsForEveryone=0
DefaultFile=”index.php index.html”
LogFormat=”%host %other %other %time1 %methodurl %code %bytesd %refererquot %uaquot”

然后设置crontab 定时每天9点运行

0 9 * * * (/home/fanlix/websoft/awstats/wwwroot/cgi-bin/awstats.pl -config=fanlix.com -update 2>&1 >/dev/null)

别忘记把执行的cmd在shell里跑一下。输出如下:

Create/Update database for config “/home/fanlix/websoft/awstats/wwwroot/cgi-bin/awstats.fanlix.com.conf” by AWStats version 6.7 (build 1.892)
From data in log file “/home/fanlix/logs/fanlix.com/http/access.log”…
Phase 1 : First bypass old records, searching new record…
Searching new records from beginning of log file…
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)…
Jumped lines in file: 0
Parsed lines in file: 233
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 233 new qualified records.

这时候应该可以用域名来访问这个统计页面了
怎么是 Index …… 改改改
怎么看不到图标 …. 改改改
怎么 ….. 不改了,太麻烦

———————–下面方法是最佳的—————————
以前的安装方法在dreamhost有些麻烦,参考了wiki的方法:
http://wiki.dreamhost.com/index.php/AWStats_Installation
1, 不使用dreamhost的subdir remap.
直接在域名根目录建立目录 awstats,作为awstats的dir目录
将wwwroot下的4个资源文件夹link 到这里

2,配制文件如上面的设置,无需改变

3,crontab 使用awstats自带的tool脚本

0 9 * * * ( /usr/bin/perl /home/fanlix/websoft/awstats/tools/awstats_buildstaticpages.pl -config=fanlix.com -update \
-awstatsprog=/home/fanlix/websoft/awstats/wwwroot/cgi-bin/awstats.pl -dir=/home/fanlix/fanlix.com/awstats 2>&1 >/dev/null )

这样会在fanlix.com/awstats/下面生成一系列静态页面

4,主html是awstats.fanlix.com.html,可以通过.htaccess或者直接link把它作为index,这样就能直接访问了
以前都是用cgi-bin目录的脚本加参数访问的,比如
http://www.fanlix.com/awstats/awstats.pl?config=www.fanlix.com
现在变成静态页面,方式好了很多。(除了不能动态调用脚本功能了)

现在终于可以看到访问统计了:http://www.fanlix.com/awstats/

目前比以前安装的结果还缺少2个功能: 访问控制、IP数据库。
控制到无所谓了,如此小的访问量笑话就笑吧;IP数据库倒是比较实用。

1 Comment »

  1. fanlix CHINA said,
    August 1, 2007 @ 23:06

    细看之下不如以前的方便啊,看来要反清复明,明日再装回动态模式

Leave a Comment