文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>AWStats与cronolog分析apache的LOG日志

AWStats与cronolog分析apache的LOG日志

时间:2005-12-30  来源:wxijin

参考多个人的文档
http://bbs.chinaunix.net/viewthread.php?tid=613098
http://www.ieasy.org/coffee/archives/cat_technology_related.html

1.apache安装

apache安装

#wget http://archive.apache.org/dist/httpd/httpd-2.0.54.tar.gz
#tar xzvf httpd-2.0.54.tar.gz
#./configure --prefix=/usr/local/apache --with-mpm=worker --enable-so --enable-ssl --enable-mods-shared=all

2.cronolog 安装,请参考我写的上一篇文章
http://blog.chinaunix.net/article.php?articleId=63868&blogId=2898

3.AWStats安装
AWStats 官方网站:http://awstats.sourceforge.net/
下载最新的版本
#老版有漏洞^-^
wget http://awstats.sourceforge.net/files/awstats-6.5.tar.gz
tar awstats-6.5.tar.gz
mv awstats-6.5 /usr/local/awstats
cd /usr/local/awstats/tools

4.配置
#直接分析 apache log 的 AWStats 设定的LOG 
#直接在此目录执行
perl awstats_configure.pl

QUOTE:
----- AWStats awstats_configure 1.0 (build 1.3) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
----->; Running OS detected: Linux, BSD or Unix
----->; Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:Program filesapache groupapacheconfhttpd.conf
Config file path ('none' to skip web server setup):

>;/etc/httpd/conf/httpd.conf

#输入apache 的配置文件目录
----->; Check and complete web server config file '/usr/local/apache

  AWStats directives already present.

----->; Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
  File awstats.model.conf updated.

----->; Need to create a new config file ?
Do you want me to build a new AWStats config/profile

file (required if first install) [y/N] ? y

#输入 y,确定产生 AWStats配置文件

----->; 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
#输入 www,为配置文件最名字,此可自取

----->; 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):

>;
#直接按下 Enter,
----->; Create config file '/etc/awstats/awstats.www.conf'

Config file /etc/awstats/awstats.www.conf created.

----->; Restart Web server with '/sbin/service httpd restart'

停止 httpd:                                                [  确定  ]

启动 httpd:                                                [  确定  ]
---->; 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

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...

#按下 Enter 继续,按两次 chmod 755 /usr/local/awstats

mkdir /var/lib/awstats

#修改配置文件

cp /etc/awstats/awstats.www.conf /etc/awstats/awstats.www.conf.bak
#备份配置文件
vi /etc/awstats/awstats.www.conf

QUOTE:
51行 LogFile="/var/log/httpd/mylog.log" 修改成-->; /LogFile="/usr/local/apache/logs/960it_access_log.%YYYY-24%MM-24%DD.log"
#修改你的LOG文件及目录,配合cronolog 和cron分析当天的日志
147行 SiteDomain="www" 修改成-->; SiteDomain="你的域名"

182行 DNSLookup=2 修改成-->; DNSLookup=1

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www -update

#上面一句要特別注意,台果你的系統先前产生大量大量的log,请等候!不要按ctal+c結束

#awstats默认会把系统默认安装的apache启动,如果你不是用这个请先把停止.


/etc/rc.d/init.d/httpd stop

/usr/local/apache/bin/apachectl  restart
测试:http://IP/awstats/awstats.pl?config=www

#定時更新
crontab -uroot -e
#在此文件的最后增加,设置成每天晚上23:50分析当天的LOG



QUOTE:
50 23 * * * root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www -update >;/dev/null 2>;

5.安全

保护/db/htdocs/www/awstat/禁止未授权用户访问
修改
#vi /usr/local/apache/conf/httpd.conf

<Directory "/usr/local/awstats/wwwroot/www">
   AuthType Basic
  AuthName "Restricted Files"
  AuthUserFile /usr/local/apache/passwd/passwords
  Require user loguser
</Directory>

其中在 /usr/local/apache/passwd/下产生passwords 的密码文件
运行如下代码产生用户名为loguser用户及其密码

 以上的设置由于要cgi支持,也增加了安全隐患可以用awstats 自带的awstats_buildstaticpages.pl来 生成静态页面 可以添加到crontab中

  50 23 * * * * /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www. -lang=cn -dir=/db/htdocs/www/awstat/ -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl

  如果www.abc.net 虚拟主机 主目录为/db/htdocs/www/ 则在浏览器中输入http://www.abc.net/awstat/awstats.www.abc.net.html 就可以通过认真访问静态页面

6.增加中awstats 显示来访者位置的插件 qqhostinfo

首先,点击这里下载插件。把它放在awstats/wwwroot/cgi-bin/plugins中。

其次,下载上一篇blog提到的分析QQWry.dat的perl脚本。

然后放在同一目录,去网上下载QQWry.Dat放在同一目录中,注意文件名一定要是QQWry.Dat,实际上是我用我的珊瑚版本的QQ的这个文件.

再编辑你得awstats配置文件,大概在LoadPlugin="hostinfo"的后面增加一行
LoadPlugin="qqhostinfo"
最后
 vi /usr/local/awstats/wwwroot/cgi-bin/plugins/qqhostinfo.pm
第17行

require的路径改

require "/usr/local/awstats/wwwroot/cgi-bin/plugins/qqwry.pl";



排行榜 更多 +
我是班长去广告版下载

我是班长去广告版下载

模拟经营 下载
什么鸭小游戏安卓版下载

什么鸭小游戏安卓版下载

策略塔防 下载
极光影院官方最新版本2025下载

极光影院官方最新版本2025下载

趣味娱乐 下载