linux安装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

接下来修改apache配置文件httpd.conf
把这行
CustomLog logs/access_log common
修改成
CustomLog "|/usr/local/sbin/cronolog /usr/local/apache2/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/apache2/logs/access-%YYYY-0%MM-0%DD-0_log"
DirData="/usr/local/apache2/htdocs/awstats/test/dirdata"(保存数据)
cp -R /usr/local/awstats/wwwroot/css/ /usr/local/apache2/htdocs/test/
cp -R /usr/local/awstats/wwwroot/icon/ /usr/local/apache2/htdocs/test/

主要用于显示图片
cd /usr/local/apache2/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/apache2/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/apache2/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/apache2/htdocs/test/htpasswd.users
Require valid-user
/usr/local/apache2/bin/htpasswd -c /usr/local/apache2/htdocs/test/htpasswd.users admin
Admin

这行是配置访问test的用户名和密码,这里是admin admin

你可能感兴趣的:(linux安装awstats对apache日志进行监测)