![]() |
|
新服务器 Awstats日志统计系统的安装(最后更新 2010-01-08)
作者:火车头 日期:2009-12-27 02:29
下载:
http://prdownloads.sourceforge.net/awstats/awstats-6.95.tar.gz
安装:
tar zxf awstats-6.95.tgz
awstats的脚本和静态文件缺省都在wwwroot目录下: 将cgi-bin目录下的文件都部署awstats.pl程序到/www/IPAccess/awstats/ 下
mv awstats-6.95/wwwroot/cgi-bin /www/IPAccess/awstats/
更多的批量更新脚本等在tools 目录下,也一并放到 /www/IPAccess/awstats/ 目录下.
修改 httpd.conf 添加以下内容
#################################################################################
################################ awststs ###############
Alias /awstatsclasses "/www/IPAccess/awstats/classes/"
Alias /awstatscss "/www/IPAccess/awstats/css/"
Alias /awstatsicons "/www/IPAccess/awstats/icon/"
ScriptAlias /awstats/ "/www/IPAccess/awstats/"
<Directory "/www/IPAccess/awstats">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#################################################################################
修改 httpd.conf 修改以下内容
将Log日志模式换成和awstats一样的格式
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" common
#LogFormat "%h %l %u %t \"%r\" %>s %b" common 原来默认的
配置文件的命名规则修改awstats.modal.conf为awstats.blog.locoy.com.conf
直接放到awstats目录
默认需要修改的
LogFile="/data/apachelogs/blog.locoy.com/Log_%YYYY-0%MM-0%DD-0.log"
AllowToUpdateStatsFromBrowser=1
DirIcons="/awstatsicons"
DirCgi="/awstats"
SiteDomain="blog.locoy.com"
配置IP到城市及国家的转换。
下载 GeoIP: wget -c http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
%./configure; make
#make install
下载 GeoIP-perl: wget -c http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz
%perl Makefile.PL; make
#make install
Geo::IPfree安装: wget -c http://search.cpan.org/CPAN/authors/id/B/BR/BRICAS/Geo-IPfree-0.8.tar.gz
%perl Makefile.PL
%make
#make install
MaxMind目前免费提供了GeoIP和GeoIPCityLite数据包:可以定期每个月从以下地址下载:
wget -c http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget -c http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
下载好后 gunzip解压GeoLiteCity.dat.gz 和 GeoIP.dat.gz得到 GeoIP.dat及GeoLiteCity.dat
此外:http://geolite.maxmind.com/download/geoip/database/下也有CSV源文件提供
完整的配置:通过在配置文件中启用GEOIP相关插件:
LoadPlugin="geoip GEOIP_STANDARD /www/IPAccess/awstats/plugins/IPData/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /www/IPAccess/awstats/plugins/IPData/GeoLiteCity.dat"
配置更为详细的纯真IP数据库包
wget -c http://www.ieasy.org/download/qqhostinfo.pm
wget -c http://www.ieasy.org/download/qqwry.pl
下载并复制到 awstats/plugins/目录下
修改,qqwry.pl中:./QQWry.Dat 修改为 /www/IPAccess/awstats/plugins/IPData/QQWry.Dat
awstats.blog.locoy.com.conf中添加
LoadPlugin="qqhostinfo"
添加授权访问目录
修改AllowOverride None 为 AuthConfig
<Directory "/www/IPAccess/awstats">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
先介绍用密码来保护服务器上的目录。
首先需要建立一个密码文件。这个文件应该放在不能被网络访问的位置,以避免被下载。例如,如果/usr/local/apache/htdocs以外的空间不能被网络访问,那么可以考虑把密码文件放在/usr/local/apache/passwd目录中。
Apache在其安装目录的bin子目录中提供了htpasswd工具,用于建立密码文件,可以这样使用:
htpasswd -c /usr/local/apache/passwd/passwords rbowen
htpasswd会要你输入密码,并要求重新输入以进行确认:
# htpasswd -c /usr/local/apache/passwd/passwords rbowen
New password: mypassword
Re-type new password: mypassword
Adding password for user rbowen
如果htpasswd不在搜索路径中,则必须使用完整路径,如:/usr/local/apache/bin/htpasswd
然后修改httpd.conf或.htaccess文件,指示服务器允许哪些用户访问并向用户索取密码。若要保护/usr/local/apache/htdocs/secret目录,则可以将下列指令写入/usr/local/apache/htdocs/secret/.htaccess或者httpd.conf的<Directory /usr/local/apache/apache/htdocs/secret>段。
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/passwd/passwords
Require user rbowen
完整效果见 http://blog.locoy.com/awstats/awstats.pl
加入定时更新日志
crontab -e
55 23 * * * /www/IPAccess/awstats/updateall.sh
service crond reload
updateall.sh中加入以下 代码 用awstats_updateall.pl更新所有网站日志
/www/IPAccess/awstats/awstats_updateall.pl -configdir=/www/IPAccess/awstats now
公共的配置信息放入公共配置文件 allsite.conf.common
LogFile="/data/apachelogs/blog.locoy.com/Log_%YYYY-0%MM-0%DD-0.log"
SiteDomain="blog.locoy.com"
AllowToUpdateStatsFromBrowser=1
Include "allsite.conf.common"
awstats看起来已经能正常运行了,但发现里面大部分中文关键字还是会乱码,可以通过启用以下模块解决
修改公共配置文件 allsite.conf.common
在配置文件中把decodeutfkeys这个plugin打开就可以了。在配置文件中找到:
#LoadPlugin="decodeutfkeys" 去掉#
再安装一个 Perl 的 URI:Escape模块
wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/URI-1.52.tar.gz -c
解压缩文件
tar zxvf URI-1.52.tar.gz
进入解压缩后目录
cd URI-1.52
然后 perl Makefile.PL
make
make install
更新一下,记录的中文搜索关键字都就可以正常显示了。
成本最小化才有失败的资本
作者:火车头 日期:2009-12-14 17:41
- 1
·若要轉載本blog内容請註明轉載地址和作者名字,禁止無權轉載/盜鏈等無恥行爲。
·如有轉載侵權請聯系刪除。
·謝謝合作。^_^
