AWStats配置与应用详解.docx
《AWStats配置与应用详解.docx》由会员分享,可在线阅读,更多相关《AWStats配置与应用详解.docx(26页珍藏版)》请在冰豆网上搜索。
AWStats配置与应用详解
【原创】【AWStats】配置Apache/WindowsIIS的日志分析工具
2009年08月20日星期四12:
09
RHEL-5.3
===================================================================================
【简介】
奇码科技的美国空间是带有详细的统计流量工具awstats,AWStats是一套免费基于Perl的网站日志分析工具。
这个工具界面较为友好,执行速度快,扩展功能众多,在国外空间使用apache服务器的,AWStats是当之无愧的首选。
Awstats是一个免费非常简洁而且强大有个性的统计工具。
它可以统计您站点的如下信息:
①访问量,访问次数,页面浏览量,点击数,数据流量等
②精确到每月、每日、每小时的数据
③访问者国家
④访问者IP
⑤Robots/Spiders的统计
⑥纺客持续时间
⑦对不同Filestype的统计信息
⑧Pages-URL的统计
⑨访客操作系统浏览器等信息
其它信息(搜索关键字等等)
AWStats是一个免费的强大而有个性的工具,带来先进的网络流量,FTP或邮件服务器统计图。
本日志分析器作为CGI或从命令行在数个图形网页中显示你日志中包含的所有可能信息。
它利用一部分档案资料就能经常很快地处理大量日志档案,它能分析日志文件来自从各大服务器工具,如Apache日志档案(NCSAcombined/XLF/ELFlogformatorcommon/CLFlogformat),WebStar,IIS(W3C的日志格式)及许多其他网站,Proxy(代理服务器)、Wap、流量服务器、邮件服务器和一些FTP服务器。
看一看这个比较表在最著名统计工具(AWStats,Analog,Webalizer,...)之间有何特点和不同的想法.
AWStats是一个在GNU通用公共许可证下发行的免费软件。
你可以看看这个许可证图表而知道你可以/不可以做。
由于AWStats工程来自网上信息,但也作为CGI、它可以与允许进入Perl,CGI与日志的大型网站主办提供商一起工作。
===================================================================================
【下载·安装】
打开页面:
#wget
也可下载
#wget
#rpm-ivhawstats-6.9-1.noarch.rpm
Preparing...###########################################[100%]
1:
awstats###########################################[100%]
-----AWStats6.9-LaurentDestailleur-----
AWStatsfileshavebeeninstalledin/usr/local/awstats
Iffirstinstall,followinstructionsindocumentation
(/usr/local/awstats/docs/index.html)tosetupAWStatsin3steps:
Step1:
InstallandSetupwithawstats_configure.pl(ormanually)
Step2:
Build/UpdateStatisticswithawstats.pl
Step3:
ReadStatistics
#whereisawstats
awstats:
/usr/etc/awstats
/usr/local/awstats
===================================================================================
【配置awstats】
awstats要求将http.conf中的CustomLog/yourlogpath/yourlogfilecommon改为CustomLog/yourlogpath/yourlogfilecombined,我看了一下,我默认的就是combined,可能现在新版本默认的都是这个吧,那就不用改了。
再进入/usr/local/awstats/tools里,运行./awstats_configure.pl启动安装向导,
#cd/usr/local/awstats/tools
#./awstats_configure.pl
-----AWStatsawstats_configure1.0(build1.8)(c)LaurentDestailleur-----
ThistoolwillhelpyoutoconfigureAWStatstoanalyzestatisticsfor
onewebserver.Youcantrytouseittoletitdoallthatispossible
inAWStatssetup,howeverfollowingthestepbystepmanualsetup
documentation(docs/index.html)isoftenabetteridea.Aboveallif:
-Youarenotanadministratoruser,
-Youwanttoanalyzedownloadedlogfileswithoutwebserver,
-Youwanttoanalyzemailorftplogfilesinsteadofweblogfiles,
-Youneedtoanalyzeloadbalancedserverslogfiles,
-Youwantto'understand'allpossiblewaystouseAWStats...
ReadtheAWStatsdocumentation(docs/index.html).
----->RunningOSdetected:
Linux,BSDorUnix
----->Checkforwebserverinstall
EnterfullconfigfilepathofyourWebserver.
Example:
/etc/httpd/httpd.conf
Example:
/usr/local/apache2/conf/httpd.conf
Example:
c:
\Programfiles\apachegroup\apache\conf\httpd.conf
Configfilepath('none'toskipwebserversetup):
>/etc/httpd/conf/httpd.conf
输入你httpd.conf的路径。
对于httpd2系列的一般都在/etc/httpd/conf/这个目录下面,这里将awstats的配置信息直接写入了httpd.conf。
----->Checkandcompletewebserverconfigfile'/etc/httpd/conf/httpd.conf'
Add'Alias/awstatsclasses"/usr/local/awstats/wwwroot/classes/"'
Add'Alias/awstatscss"/usr/local/awstats/wwwroot/css/"'
Add'Alias/awstatsicons"/usr/local/awstats/wwwroot/icon/"'
Add'ScriptAlias/awstats/"/usr/local/awstats/wwwroot/cgi-bin/"'
Add''directive
AWStatsdirectivesaddedtoApacheconfigfile.
----->Needtocreateanewconfigfile?
DoyouwantmetobuildanewAWStatsconfig/profile
file(requirediffirstinstall)[y/N]?
y
----->Defineconfigfilenametocreate
Whatisthenameofyourwebsiteorprofileanalysis?
Example:
Example:
demo
Yourwebsite,virtualserverorprofilename:
>
下面是要生成conf文件的名称了,因为conf文件的名称都是awstats.yourdomainname.conf格式的,所以这里要求你输入你要监测的域名,其实这个域名只是与其他域名相区分的,并不一定非要真实的。
----->Defineconfigfilepath
Inwhichdirectorydoyouplantostoreyourconfigfile(s)?
Default:
/etc/awstats
Directorypathtostoreconfigfile(s)(Enterfordefault):
>
这里是让你输入配置文件的路径,直接回车会执行默认的,当然你也可以自己定义。
----->Createconfigfile'/etc/awstats/.conf'
Error:
Failedtoopen'/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'forread.
那是因为该路径找不到awstats.model.conf文件可以修改,而该文件所在的目录是/usr/local/www/awstats/cgi-bin,既然程序只读固定的路径,那就按照它要读取的路径进行相关设置,然后重新配置一次。
#cp/usr/etc/awstats/awstats.model.conf/usr/local/awstats/wwwroot/cgi-bin/
#./awstats_configure.pl
----->Createconfigfile'/etc/awstats/.conf'
Configfile/etc/awstats/.confcreated.
----->Addupdateprocessinsideascheduler
Sorry,configure.pldoesnotsupportautomaticaddtocronyet.
Youcandoitmanuallybyaddingthefollowingcommandtoyourcron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl-update-config=
Orifyouhaveseveralconfigfilesandpreferhavingonlyonecommand:
/usr/local/awstats/tools/awstats_updateall.plnow
PressENTERtocontinue...
ASIMPLEconfigfilehasbeencreated:
/etc/awstats/.conf
Youshouldhavealookinsidetocheckandchangemanuallymainparameters.
Youcanthenmanuallyupdateyourstatisticsfor''withcommand:
>perlawstats.pl-update-config=
Youcanalsoreadyourstatisticsfor''withURL:
>http:
//localhost/awstats/awstats.pl?
config=
PressENTERtofinish...
------------------------------------------------------------------------------------------------------------------------------------
更新数据
#/usr/local/awstats/wwwroot/cgi-bin/awstats.pl--update-config=
Error:
AWStatsdatabasedirectorydefinedinconfigfileby'DirData'parameter(/var/lib/awstats)doesnotexistorisnotwritable.
Setup('/etc/awstats/.conf'file,webserverorpermissions)maybewrong.
Checkconfigfile,permissionsandAWStatsdocumentation(in'docs'directory).
对于/var/lib/awstats目录没有写入权限造成的
#chmod777/var/lib/awstats
chmod:
cannotaccess`/var/lib/awstats':
Nosuchfileordirectory
#mkdir/var/lib/awstats
#chmod777/var/lib/awstats
更新数据
#/usr/local/awstats/wwwroot/cgi-bin/awstats.pl--update-config=
Create/Updatedatabaseforconfig"/etc/awstats/.conf"byAWStatsversion6.9(build1.925)
Fromdatainlogfile"/var/log/httpd/mylog.log"...
Error:
Couldn'topenserverlogfile"/var/log/httpd/mylog.log":
Nosuchfileordirectory
Setup('/etc/awstats/.conf'file,webserverorpermissions)maybewrong.
Checkconfigfile,permissionsandAWStatsdocumentation(in'docs'directory).
日志路径错位造成的
#vi/etc/awstats/.conf
将
LogFile="/var/log/httpd/mylog.log"
改成
LogFile="/var/log/httpd/access_log"
更新数据
#/usr/local/awstats/wwwroot/cgi-bin/awstats.pl--update-config=
Create/Updatedatabaseforconfig"/etc/awstats/.conf"byAWStatsversion6.9(build1.925)
Fromdatainlogfile"/var/log/httpd/access_log"...
Phase1:
Firstbypassoldrecords,searchingnewrecord...
Searchingnewrecordsfrombeginningoflogfile...
Phase2:
Nowprocessnewrecords(Flushhistoryondiskafter20000hosts)...
Jumpedlinesinfile:
0
Parsedlinesinfile:
8
Found0droppedrecords,
Found0corruptedrecords,
Found0oldrecords,
Found8newqualifiedrecords.
#cp/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf/etc/awstats/common.conf
#vi/etc/awstats/.conf
Include"common.conf"
#LogFile="/var/log/httpd/mylog.log"
LogFile="/var/log/httpd/access_log.%YYYY-24%MM-24%DD-24"
#%YYYY-24%MM-24%DD-24是指用24小时前的年月日日志文件名,如access_log.20061206
#LogFile="gzip-d|"
SiteDomain=""
HostAliases="127.0.0.1localhost"
DefaultFile="index.html"
DirData="/var/lib/awstats"
DirData="/home/cgi-bin/awstats/data/"
添加定时分析指令
#crontab-e
201***/usr/local/awstats/wwwroot/cgi-bin/awstats.pl--update-config=
===================================================================================
【配置apache】
#vi/etc/httpd/conf/httpd.conf
281DocumentRoot"/var/www/html/"
282DocumentRoot"/usr/local/awstats/wwwroot"
这里将awstats的配置信息直接写入了httpd.conf
*****************************************************************
Pleaseaddthefollowingtoyourapacheconfig,andrestart.
#
#DirectivestoallowuseofAWStatsasaCGI
#
Alias/awstatsclasses“/usr/local/www/awstats/classes/”
Alias/awstatscss“/usr/local/www/awstats/css/”
Alias/awstatsicons“/usr/local/www/awstats/icons/”
ScriptAlias/awstats/“/usr/local/www/awstats/cgi-bin/”
#
#ThisistopermitURLaccesstoscripts/filesinAWStatsdirectory.
#
OptionsNone
AllowOverrideNone
Orderallow,deny
Allowfromall
*****************************************************************
对要分析的虚拟主机,将CustomLoglogs/access_xxx_logcommon中的common改成combined。
从新启动apache
#servicehttpdrestart
------------------------------------------------------------------------------------------------------------------------------------
用浏览器访问:
http:
//server/awstats/awstats.pl?
config=mysite
http:
//218.*.*.254/awstats/awstats.pl?
config=
Theserverencounteredaninternalerrorormisconfigurationandwasunabletocompleteyourrequest.
----------------------------------------------------------------------------------------------