[code:1:794ef16052]-----> Create config file '/etc/awstats/awstats.www.bestunix.net.conf'
Config file /etc/awstats/awstats.www.bestunix.net.conf created.[/code:1:794ef16052]
创建完配置文件以后会自动重启httpd服务。
[code:1:794ef16052]-----> Restart Web server with '/sbin/service httpd restart'
停止 httpd [ 确定 ]
启动 httpd [ 确定 ][/code:1:794ef16052]
下面的都是直接回车就可以了
[code:1:794ef16052]-----> 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/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.bestunix.net
Or if you have several config files and prefer having only one command:;
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
A SIMPLE config file has been created:; /etc/awstats/awstats.www.bestunix.net.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.bestunix.net' with command:;
> perl awstats.pl -update -config=www.bestunix.net
You can also read your statistics for 'www.bestunix.net' with URL:;
> http:;//localhost/awstats/awstats.pl?config=www.bestunix.net
Press ENTER to finish...[/code:1:794ef16052]
剩下的工作我们就需要手工完成了。
第一, 在crontab里手工加进去
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.bestunix.net,因为这个程序是通过分析日志来进行流量统计的,如果你的日志文件很大的话是很耗系统资源的。还好,我的流量不大,我设定的是每个小时运行一次,你如果服务器比较繁忙的话也可以每天夜里运行一次。当然你也可以手工运行上面的命令来进行更新统计信息。
第二,conf文件的配置:
LogFile
指定你要分析的日志文件,默认是/var/log/httpd/mylog.log,可以根据你的需要调整,如果你要分析httpd的全部日志的就是/var/log/httpd/access_log,我们一般就选这个了。
LogType
log类型,默认是web log,不用修改,如果你不是的话就自己照说明改了。
LogFormat
log格式,一般情况下如果是apache的话就是1,iis就是2,默认不用修改,你也可以照说明自定义,呵呵,我还不太清楚怎么定义。
LogSeparator
log中的分隔符,默认不用修改,如果上面的格式是你自定义的话这里也要修改了
DNSLookup
默认不用修改
DirData
生成的日志分析结果的保存路径,默认是/var/lib/awstats,你如果要使用默认的路径的话,这个目录是需要手工创建的,注意这个路径必须是可读写的。
下面四项都是在配置时,不用修改。
DirCgi cgi的路径,这里都是相对于网站根目录的绝对路径
DirIcons icon的路径
SiteDomain 域名:www.bestunix.net
HostAliases 主机别名
AllowToUpdateStatsFromBrowser
下面这项是是否允许从浏览器里更新统计文件,默认是0不允许,如果我们改为1的话,就需要apache的属主用户对/var/lib/awstats目录有读写权限,并对/var/log/httpd目录有读取权限
AllowFullYearView
这个不用修改默认值。awstats默认是以月为单位进行日志分析,如果我们要分析整年的日志的可以在这里设置,因为分析整年的日志的话可能要消耗很多系统资源。如果你需要对年日志进行分析的话,建议手工启动。
这样最基本的配置就完成了,我们可以通过http://www.bestunix.net awstats/awstats.pl?config=www.bestunix.net来查看统计信息。
常见问题:
问题一,在第一次进行日志分析时候就出错了
[code:1:794ef16052][root@demo conf.d]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.bestunix.net
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.www.bestunix.net.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).[/code:1:794ef16052]
这个是因为在/etc/awstats/awstats.www.bestunix.net.conf中DirData中定义的目录启动apache的用户没有写得权限,更改目录或更改权限都可以解决。
问题二,出来的页面里所有的流量统计都是空的。
同样是/etc/awstats/awstats.www.bestunix.net.conf的问题,在这个文件里有一行
LogFile="/var/log/httpd/mylog.log"
我们一般情况下把这个路径改为”/var/log/apache/access.log”就可以了,如果你设了很多虚拟主机,每个主机都配置了不同的log的话,在这里指定你要统计的那个主机的log文件就可以了。