技术开发 频道

RHEL5.4下LAMP平台搭建及基本测试

  5、使用awstats分析Web日志

[root@localhost media]# tar -zxvf awstats-6.9.tar.gz -C /usr/local/src/
[root@localhost media]# mv
/usr/local/src/awstats-6.9/ /usr/local/src/awstats
[root@localhost media]# cd
/usr/local/src/awstats/tools/
[root@localhost tools]# .
/awstats_configure.pl
And then, run configure.pl from
this location.
Do you want to
continue setup from this NON standard directory [yN] ? y
Warning: You Apache config file contains directives to write
'common' log files
This means that some features can
't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ? y
Do you want me to build a
new AWStats config/profile
file (required
if first install) [y/N] ? y
-----> Define config file name to create
What is the name of your web site or profile analysis
?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.crazylinux.com
-----> Define config file path
In which directory
do you plan to store your config file(s) ?
Default:
/etc/awstats
Directory path to store config file(s) (Enter
for default):
>

-----> 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/src/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.crazylinux.com
Or
if you have several config files and prefer having only one command:
/usr/local/src/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...
Press ENTER to finish...

[root@localhost tools]# vim
/etc/awstats/awstats.www.crazylinux.com.conf  把LogFile修改
LogFile="/usr/local/apache2/logs/www.crazylinux.com.access.log"
[root@localhost awstats]# touch /usr/local/apache2/logs/www.crazylinux.com.access.log

  在此先把access.log的日志格式修改一下,这里选择日志的格式为 combined,而不是common,awstats解析不了common

[root@localhost awstats]# cat /usr/local/apache2/conf/extra/httpd-vhosts.conf
NameVirtualHost
192.168.0.10
<VirtualHost 192.168.0.10>
    DocumentRoot
"/usr/local/apache2/htdocs/crazylinux"
    ServerName www.crazylinux.com
    ErrorLog
"logs/www.crazylinux.com.error.log"
    CustomLog
"logs/www.crazylinux.com.access.log" combined
</VirtualHost>

<VirtualHost 192.168.0.10>
    DocumentRoot
"/usr/local/apache2/htdocs/google"
    ServerName www.google.com
    ErrorLog
"logs/www.google.com.error.log"
    CustomLog
"logs/www.google.com.access.log" common
</VirtualHost>
[root@localhost awstats]# perl
/usr/local/src/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.crazylinux.com
Create
/Update database for config "/etc/awstats/awstats.www.crazylinux.com.conf" by AWStats version 6.9 (build 1.925)
From data in log file
"/usr/local/apache2/logs/www.crazylinux.com.access.log"...
Phase
1 : First bypass old records, searching new record...
Direct access after last parsed record (after line
57)
Jumped lines in file:
57
Found
57 already parsed records.
Parsed lines in file:
8675
Found
0 dropped records,
Found
0 corrupted records,
Found
0 old records,
Found
8675 new qualified records.
[root@localhost tmp]# crontab
-l
* */5 * * * /usr/bin/perl /usr/local/src/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.crazylinux.com
[root@localhost tmp]# service crond restart
Stopping crond: [  OK  ]
Starting crond: [  OK  ]
[root@localhost tmp]# chkconfig crond on

  在之前把APACHE全局的CustomLog注释掉

#CustomLog "logs/access_log" combined
测试:
[root@localhost
~]# cat /usr/local/apache2/htdocs/crazylinux/awstats.html
<html>
<head>
<meta http-equiv=refresh content="0;url=http://www.crazylinux.com/awstats/awstats.pl?
config=www.crazylinux.com">
</head>
<body>
</body>
</html>

  在client上IE中输入http://www.crazylinux.com/awstats.html

使用awstats分析Web日志

0
相关文章