Category Archives: Linux

配置awstats,使之与搜索引擎的兼容

1、awstats对搜索引擎的支持问题。google等所使用的为utf-8编码,所以,需要使用decodeutfkeys
即启用LoadPlugin=”decodeutfkeys”
2、但再次运行测试脚本时,却提示perl缺少Encoding模块。需要安装Encode,URI-1.35.tar.gz。
下载地址ftp://ftp.tsinghua.edu.cn/mirror/CPAN/modules/by-module/Encode/Encode-2.12.tar.gz
ftp://ftp.tsinghua.edu.cn/mirror/CPAN/modules/by-module/URI/URI-1.35.tar.gz
或者使用命令cpan。然后install即可
3、解包安装
#tar -xzvf Encode-2.12.tar.gz
#tar -xzvf URI-1.35.tar.gz
#cd Encode-2.12.tar.gz
#chmod +x Makefile.PL
#perl Makefile.PL
#make;make install
#cd URI-1.35
#chmod +x Makefile.PL
#perl Makefile.PL
#make;make install
4、刷新awstats的页面,正常。错误消失:)

awstats的反向解析

为了显示访问者的国家等地理信息和使用whois功能,需要给awstats安装插件。
1、执行
meteor 12-03添加:需要首先安装zlib1g-dev的包。不然会出错。而且,最新的geoip似乎直接叫geoip.tar.zg
root@trotter opt]# wget http://www.maxmind.com/download/geoip/api/c/GeoIP-1.3.8.tar.gz
[root@trotter opt]# wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz
[root@trotter opt]# tar -xzvf GeoIP-1.3.8.tar.gz
[root@trotter opt]# tar -xzvf Geo-IP-1.27.tar.gz
[root@trotter opt]# cd GeoIP-1.3.8
[root@trotter GeoIP-1.3.8]# ./configure
[root@trotter GeoIP-1.3.8]# make
[root@trotter GeoIP-1.3.8]# make install
[root@trotter GeoIP-1.3.8]# cd ../Geo-IP-1.27
[root@trotter Geo-IP-1.26]# chmod +x Makefile.PL
[root@trotter Geo-IP-1.26]# perl Makefile.PL
[root@trotter Geo-IP-1.26]# make
[root@trotter Geo-IP-1.26]# make install
其中,注意geoip和geo-ip都有最新版。可以在网站下载。注意运行时对相应版本。
地址http://www.maxmind.com/download/geoip/api/c/
wget http://www.maxmind.com/download/geoip/api/perl/
XWhois安装:(该模块安装后,就可以进行IP反解析)
[root@trotter opt]# wget http://search.cpan.org/CPAN/authors/id/V/VI/VIPUL/Net-XWhois-0.90.tar.gz
[root@trotter opt]# tar -xzvf Net-XWhois-0.90.tar.gz
[root@trotter opt]# cd Net-XWhois-0.90
[root@trotter Net-XWhois-0.90]# chmod +x Makefile.PL
[root@trotter Net-XWhois-0.90]# perl Makefile.PL
[root@trotter Net-XWhois-0.90]# make
[root@trotter Net-XWhois-0.90]# make install
ps:默认我似乎没有编译所需要的包。需要安装build-essentiel。
2、对awstats进行配置
root@trotter wwwroot]# cd /path/to/apache/cgi-bin/awstats
[root@trotter awstats]# vi awstats.computer.ouc.edu.cn.conf(去掉下面几行前面的#)
LoadPlugin="geoip GEOIP_STANDARD"
LoadPlugin="hostinfo"
3、运行命令并查看分析结果:
[root@trotter awstats]# ./awstats.pl -update -config=computer.ouc.edu.cn
结果正常
 
ps:其他的一些信息,以下为转贴
4.在corntab里添加任务,定义每天晚上1:30分自动进行先一天的日志分析:
[root@trotter awstats]# vi /var/spool/cron/root (添加下面一行)
30 1 * * * /var/www/cgi-bin/awstats/awstats.pl -update -config=gbunix.com
[root@trotter awstats]# /etc/init.d/crond restart
5.你的日志分析结果不愿意给别人看到吗?给访问加个锁。
这个需要Apache mod_auth模块的支持,先给Apache安装mod_auth模块:
./apxs -c -i /usr/local/src/httpd-2.0.4/…./mod_auth.c
再在httpd.conf 中添加
LoadModule auth_module        modules/mod_auth.so
配置需要认证的目录:
<Directory "/var/www/cgi-bin/awstats/">
  AuthType Basic
  AuthName "Restricted Files"
  AuthUserFile /etc/httpd/passwords
  Require user trotter
</Directory>
运行如下代码产生用户名为trotter用户及其密码
/etc/httpd/bin/htpasswd -c /usr/local/apache2/passwd/passwords  trotter
6.好了,你现在重新启动一下你的apache,然后通过浏览器访问,服务器应该提示你输入用户名和密码,输入密码后,你就可以看到你的日志分析结果了
 
 

awstats的配置

在设置跳过文件时,需要修改
SkipFiles=""
不过这里需要满足标准的正则表达式,比如,如果要隐藏/test/目录,那么就需要写成
SkipFiles="REGEX[^/test/*]’
 
哈哈,变态把

awstats配置的补充说明

9、重新启动apache2。出问题了。。
Alias /awstatsclasses "/usr/share/doc/awstats/examples/wwwroot/classes/"
Alias /awstatscss "/usr/share/doc/awstats/examples/wwwroot/css/"
Alias /awstatsicons "/usr/share/doc/awstats/examples/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/doc/awstats/examples/wwwroot/cgi-bin/"
这个路径不对。修改巴。
首先屏蔽这几行。apache2正常启动。但统计中的图片无法显示了。。。
检查。发现其实并不需要把awstats中的静态文件复制,只需要在apache2.conf里面正确设定路径就可以
了:)

Debian下配置AWStats

1、安装awstats。直接使用apt-get install awstats
2、检察awstats 是否正常。awstias在在ubuntu上有/etc/awstats和/usr/share/awstats 目录。
而根据网上教程,需要找到他的pl文件来完成配置。
使用find / -name awstats.pl 来进行查找,结果为/usr/lib/cgi-bin/awstats.pl.
还是没有找到配置文件。只好find / -name *.pl|more
结果,n多的文件。。。。不过显示了/usr/share/doc/awstats/examples/
3、运行./awstats_configure.pl
会有提示。第一步,指定apache2配置文件的准确位置。
第二步,生成配置文件。第一次安装时必须。会提示你输入web的域名
第三步,选择配置文件的存放目录。默认是/etc/awstats
结果:Error: Failed to open ‘/usr/share/doc/awstats/examples/wwwroot/cgi-
 
bin/awstats.model.conf’ for read.
仔细看执行过程,有Warning: AWStats standard directory on Linux OS is ‘/usr/local/awstats’.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/usr/share/doc/awstats/examples
to standard directory:
/usr/local/awstats
查看安装说明把。。README.Debian。
4、无奈,只好man awstats_configure.pl。结果发现
 
$AWSTATS_ICON_PATH=’/usr/local/awstats/wwwroot/icon’;
$AWSTATS_CSS_PATH=’/usr/local/awstats/wwwroot/css’;
$AWSTATS_CLASSES_PATH=’/usr/local/awstats/wwwroot/classes’;
$AWSTATS_CGI_PATH=’/usr/local/awstats/wwwroot/cgi-bin’;
$AWSTATS_MODEL_CONFIG=’/etc/awstats/awstats.model.conf’;                # Used only when
 
configure ran on linux
$AWSTATS_DIRDATA_PATH=’/var/lib/awstats’
 
所以,可能问题在这个地方。不管了。备份一下。然后修改
icon的路径/usr/share/awstats/icon
css文件的路径/usr/share/doc/awstats/examples/css
没有找到/usr/local/awstats/wwwroot/classes对应目录。
cgi目录也没有相应的。只好定位到/usr/lib/cgi-bin
awstats.model.conf没有找到。但发现example目录下有一个awstats.model.conf.gz。解压缩,发现
awstats.model.conf就在这里;)于是仅仅修改
 
$AWSTATS_MODEL_CONFIG=’/usr/share/doc/awstats/examples/awstats.model.conf’;结果运行,不成功
 
。。
5、将awstats.model.conf复制到/etc/awstats中。然后重新运行。提示
—–> Create config file ‘/etc/awstats/awstats.computer.ouc.edu.cn.conf’
 Config file /etc/awstats/awstats.computer.ouc.edu.cn.conf created.
 
—–> 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/share/doc/awstats/examples/wwwroot/cgi-bin/awstats.pl -update –
 
config=computer.ouc.edu.cn
Or if you have several config files and prefer having only one command:
/usr/share/doc/awstats/examples/tools/awstats_updateall.pl now
看来生成正常。但以前我执行过,所以。。
6、按照提示继续把。执行./awstats.pl -update -config=computer.ouc.edu.cn
提示With data in log file "/var/log/httpd/mylog.log"…
Error: Couldn’t open server log file "/var/log/httpd/mylog.log" : 没有那个文件或目录
应该是日子的问题。嘿嘿。修改/etc/awstats下的配置文件。把路径指向apache2的日子位置
7、重新执行。终于正常了
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: 2581
 Found 0 dropped records,
 Found 4 corrupted records,
 Found 0 old records,
 Found 2577 new qualified records.
8、现在就是设置awstats的web问题了。
用web访问awstats.pl。正常显示。嘿嘿。不过似乎图片等不正常。看看路径
http://computer.ouc.edu.cn/awstatsicons/browser/msie.png。然后使用无敌find大法。
find / -name msie.png。结果/usr/share/awstats/icon/browser/msie.png
嘿嘿。把usr/share/awstats/icon所有文件复制到web目录相应位置就行了。正常。嘿嘿