AWStats安装手册

时间:2007-03-11 13:07:17   来源:  作者:  点击:次  出处:技术无忧
关键字:AWStats 安装手册

AWStats安装手册
作者:FunBSD
最后更新:2006年2月25日 


目录
cronolog
apache
awstats
plugin
reference


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


cronolog
cronolog是一个可以根据日期格式轮循日志的工具。

网址:http://cronolog.org/

pkg_add -r cronolog.tbz


apache
配置虚拟主机,日志格式要使用combined:

<VirtualHost *:80>
ServerName www.funbsd.net
DocumentRoot /home/funbsd/www
CustomLog "|/usr/local/sbin/cronolog /var/log/httpd/www.funbsd.net.%w.log" combined
</VirtualHost>


每天删除最旧的日志文件(crontab -e):

0 0 * * * /var/log/httpd/httpd_log.sh


脚本内容(/var/log/httpd/httpd_log.sh):

rm -f `dirname $0`/*.`date -v+1d +%w`.log
#Linux:rm -f `dirname $0`/*.`date -d 1day +%w`.log


设置执行权限:

chmod 755 /var/log/httpd/httpd_log.sh


返回页首


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


awstats
awstats是一个功能强大的web,mail,ftp日志分析和统计工具。

网址:http://awstats.sourceforge.net/

安装:

cd /home/pkg
fetch http://awstats.sourceforge.net/files/awstats-6.3.tgz

cd /usr/local
tar zxvf /home/pkg/awstats-6.3.tgz
mv awstats-6.3 awstats

chown -R root:wheel awstats
chmod -R 755 awstats 


添加主机(可以添加多个):

cd /usr/local/awstats/tools
perl awstats_configure.pl

Config file path ('none' to skip web server setup):
> /usr/local/etc/apache2/httpd.conf

Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

Your web site, virtual server or profile name:
> www.funbsd.net

Directory path to store config file(s) (Enter for default):
> /usr/local/etc/awstats
 


修改主机配置(/usr/local/etc/awstats/awstats.www.funbsd.net.conf),与httpd.conf保持一致:

#LogFile="gzip -d < log.gz |"
#LogFile="awstats/tools/logresolvemerge.pl *.log |"
LogFile="/var/log/httpd/www.funbsd.net.%Dw-1.log"
LogType=W
LogFormat=1
SiteDomain="www.funbsd.net"
HostAliases="funbsd.net www.funbsd.net 192.168.0.100"
DNSLookup=2

DirData="/var/lib/awstats"
AllowToUpdateStatsFromBrowser=0
CreateDirDataIfNotExists=0
SaveDatabaseFilesWithPermissionsForEveryone=0
PurgeLogFile=0
ArchiveLogRecords=0
KeepBackupOfHistoricFiles=1

DefaultFile="index.htm index.html index.php"
SkipHosts="localhost REGEX[^192\.168\.]"
SkipFiles="REGEX[^\/images] REGEX[^\/css] REGEX[^\/scripts] REGEX[^\/awstats] REGEX[^*\.gif]"
Lang="auto"

#LoadPlugin="decodeutfkeys"
#LoadPlugin="hashfiles"
#LoadPlugin="geoip GEOIP_STANDARD"
#LoadPlugin="userinfo"
#LoadPlugin="hostinfo"

#Include ""


安装过程会自动在httpd.conf文件中添加下面的配置信息:

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/"
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory> 


重启Apache:

/usr/local/etc/rc.d/apache2.sh restart

统计旧的主机日志:

mkdir -p /var/lib/awstats
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.funbsd.net \
-update -Logfile=/var/log/httpd/www.funbsd.net.log
 


定时统计所有主机日志:

0 * * * * /usr/local/awstats/tools/awstats_updateall.pl now -configdir=/usr/local/etc/awstats > /dev/null 2>&1


测试:

http://www.funbsd.net/awstats/awstats.pl?config=www.funbsd.net


返回页首


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


plugin
awstats支持插件功能,以GeoIP为例:

网址:http://www.maxmind.com/app/perl?rId=awstats

cd /home/pkg
fetch http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar zxvf GeoIP.tar.gz
cd GeoIP-*; ./configure; make; make install

cd /home/pkg
fetch http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz
tar zxvf Geo-IP-*.tar.gz
cd Geo-IP-*; perl Makefile.PL; make; make install
 


定时更新GeoIP库:

MAILTO=postmaster@funbsd.net
0 0 * * 0 cd /usr/local/share/GeoIP/ && fetch http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz && gunzip -f GeoIP.dat.gz


也可以从pkg安装各插件(参考配置文件PLUGINS一节):

pkg_add -r p5-URI.tbz
pkg_add -r p5-Encode-HanConvert.tbz
pkg_add -r p5-Storable.tbz
pkg_add -r GeoIP.tbz
pkg_add -r p5-Geo-IP.tbz
pkg_add -r p5-Net-XWhois.tbz
 


加载插件(/usr/local/etc/awstats/awstats.www.funbsd.net.conf):

LoadPlugin="decodeutfkeys"
LoadPlugin="hashfiles"
LoadPlugin="geoip GEOIP_STANDARD"
LoadPlugin="hostinfo"
 


reference
车东的学习笔记:

http://www.chedong.com/tech/awstats.html

更多电脑、家电软硬件维修资讯请访问维修技术


文章评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面