使用awstats对apache日志进行监测

 

wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
wget http://prdownloads.sourceforge.net/awstats/awstats-6.7.tar.gz
cronolog是用来改动日志的格式以适合awstats的分析
cronolog非常好装,下载后解包,./configure && make && make install即可
修改httpd.conf文件
把这行CustomLog logs/access_log common修改成
CustomLog "|/usr/local/sbin/cronolog /usr/local/apache/logs/access-%Y%m%d_log" combined
Cronolog这个脚本在cronolog装完以后就会产生
把awstats解包,并cp -r awstats-6.7/ /usr/local/awstats
cd /usr/local/awstats
perl tools/awstats_configure.pl
在Your web site, virtual server or profile name:里
输入你的IP(域名),其他基本都能回车和y
修改awstats的设置文件
vi /etc/awstats/awstats.192.168.0.104.conf
LogFile="/usr/local/apache/logs/access-%YYYY-0%MM-0%DD-0_log"
DirData="/usr/local/apache/htdocs/awstats/test/dirdata"(保存数据)
cp -R /usr/local/awstats/wwwroot/css/ /usr/local/apache/htdocs/test/
cp -R /usr/local/awstats/wwwroot/icon/ /usr/local/apache/htdocs/test/
主要用于显示图片
Cd /usr/local/apache/htdocs
mkdir -p awstats/test/dirdata
perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=192.168.0.104
perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=192.168.0.104 -output -staticlinks > /usr/local/apache/htdocs/test/index.html
这两个命令写入crontab 中
30 * * * * /usr/bin/perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=192.168.0.104
30 * * * * /usr/bin/perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=192.168.0.104 -output -staticlinks > /usr/local/apache/htdocs/test/index.html
两个命令是用来生成index.html文件
设置test的访问权限
#  SSLRequireSSL
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
   AuthName "Awstats Access"
   AuthType Basic
   AuthUserFile /usr/local/apache/htdocs/test/htpasswd.users
   Require valid-user
/usr/local/apache/bin/htpasswd -c /usr/local/apache/htdocs/test/htpasswd.users admin
Admin
这行是设置访问test的用户名和密码,这里是admin admin

你可能感兴趣的:(使用awstats对apache日志进行监测)