Awstats日志系统配置文件和错误归纳

JokerCch 2012-12-09

1、  apache配置文件修改:

修改%apache%/conf/httpd.conf
修改为:
CustomLog logs/access_log combined
 
2配置awstats:
 
# cd /etc/awstats/ (这个目录是存放awstats配置文件的)
# vi awstats.[url]www.test.net.conf[/url]
 
检查并做如下修改
# LogFile="/var/log/httpd/mylog.log"
LogFile="/usr/local/apache2/logs/access_log"  (修改你要分析的日志文件的路径)
 
//日志分析结果输出目录 确保该目录有写权限
DirData="/var/www/awstats/test/dirdata"
 
指到apche的日志
LogType=W
表示分析的是web日志
LogFormat=1      (如果是分析apache 可以用默认的,如果是分析IIS就应该选2)
表示日志格式为combined
SiteDomain="s1.domain1.com"
域名
HostAliases="s1.domain1.com www.s1.domain1.com 127.0.0.1 localhost"
这个变量的意思是这个域的别名.即多个域名对应同一网站的情况,这句是自动生成的.我这里没有用到所以就没有改.
 
AllowToUpdateStatsFromBrowser=1 允许查看的时候进行更新日志数据

 
我碰到的错误:
 
运行:perl /tmp/awstats-7.0/wwwroot/cgi-bin/awstats.pl -update -config=rhel5.fjl.com
 
1)如果是第一次运行更新的话,awstats会出现错误:
 
AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log。
其实从错误信息中不难看出原因,解决办法就是把用分析的日志文件删除,重新加载即可。
为了让系统自动作业,把命令加入系统的crontab,
 
2)
Error: AWStats database directory defined in config file by ‘DirData‘ parameter (/var/lib/awstats) does not exist or is not writable.
Setup (‘/etc/awstats/awstats.s1.domain1.com.conf‘ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs‘ directory).
 
同时访问http://192.168.0.111t/awstats/awstats.pl?config=s1.domain1.com提示Error: AWStats database directory defined in config file by ‘DirData‘ parameter (/var/lib/awstats) does not exist or is not writable.
Setup (‘/etc/awstats/awstats.s1.domain1.com.conf‘ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs‘ directory).
 
很明显是/var/lib/awstats这个目录不存在
这里需要说明,这个路径是由配置文件/etc/awstats/awstats.s1.domain1.com.conf里面的DirData参数决定的,表示存放数据库的地方.我没有修改所以依然是默认值DirData="/var/lib/awstats"
既然提示不存在,现在就来新建它
cd /var/lib
mkdir awstats
 
3)
还有个权限问题,我是修改/tmp/awstats的目录权限为755,得到解决,
具体不清楚,有说只需要改wwwroot目录就可以了。
 
 
[root@CentOS awstats]# crontab -e
30 23 * * * root perl /opt/awstats-6.6/wwwroot/cgi-bin/awstats.pl -update -config=www.test.net (每天晚上11:30进行日志分析)
访问权限配置
有时候网站的日志信息不想给竞争对手看到,所以需要对日志查看进行授权,授权方式如下:
编辑apache的配置文件 vi /usr/local/apache2/conf/httpd.conf
<Directory "/opt/awstats-6.6/wwwroot">
    Options None
  # AllowOverride None
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /usr/local/apache2/conf/passwords
    Require user dbasky
</Directory>
利用apapche的htpasswd生成个系统的用户,达到系统的加密:
/usr/local/apache2/bin/htpasswd -c /usr/local/apache2/conf/passwords admin
此时输入二次密码确认密码.
配置完成后,重启apapche,ok!awstats就配置完成了,可以看看我们的成果了:

相关推荐