Chinaunix首页 | 论坛 | 博客
  • 博客访问: 170615
  • 博文数量: 20
  • 博客积分: 542
  • 博客等级: 中士
  • 技术积分: 240
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-23 09:44
文章分类

全部博文(20)

文章存档

2012年(3)

2011年(17)

分类: LINUX

2011-08-18 15:38:55

1.    安装
1.1.    Apache的安装
#tar –xvzf httpd-2.0.59.tar.gz
#cd httpd-2.0.59
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-cgi –enable-rewrite
#make
#make install
将apache中入自启动
#cp bin/apachectl /etc/init.d/httpd
#vi /etc/init.d/httpd
添加如下段
并在#!/bin/sh下加入以下几句
# add for chkconfig
# chkconfig: 2345 70 30
# description: Activate/Deactive Apache Web Server
# processname: httpd
保存后退出。

最后执行 chkconfig --add httpd ,将apache的自启动文件加到rc.d下的对应目录下,只有这样,Linux才能正确完成开机自启动。

1.2.    Awstats安装
Rpm –ivh Awstats-6.6-1.noarch.rpm
安装即可。
2.    配置
2.1.    Apache配置
在httpd.conf中添加如下:
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#

    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Awstats Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user

创建用户密码配置:
/usr/local/apache2/bin/htpasswd /usr/local/nagios/etc/htpasswd.users nagiosadmin

虚拟主机及日志定义

    ServerAdmin admin@uonenet.com
    DocumentRoot /data/www/
    ServerName
    ErrorLog logs/-error_log
    CustomLog logs/-access_log combined
 
    Options ExecCGI FollowSymLinks
    AllowOverride all
    Allow from all
    Order allow,deny
    AddHandler cgi-script .cgi
    AddHandler fastcgi-script .fcgi
 




2.2.    Awstats配置
进入awstats安装目录工具下.
/usr/local/awstats/tools
Perl awstats_configure.pl
按相关的提示加入相应的站点.

编写日志和分析脚本.sh内容如下:
/bin/cp /usr/local/apache2/logs/-access_log /usr/local/apache2/logs/-access_log.`date +%Y%m%d`
cp /dev/null /usr/local/apache2/logs/-access_log
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config= -lang=cn
Chmod +x

2.3.    添加计划任务
Vi /etc/crontab
添加如下:
10 8 * * * root run-parts /usr/local/apache2/logs/.sh
表示每天早上八点十分开始执行此脚本分析

浏览:
http://192.168.1.1/awstats/awstats.pl?config=


2.4.    awstat分析vsftp日志
2.4.1.    修改vsftp的日志格
 vi /etc/vsftpd/vsftpd/conf
 xferlog_enable=YES  
xferlog_std_format=YES  
xferlog_file=/var/log/vsftpd.log
如果有vsftpd_log_file=/XXX/XXX请把它注释掉
上面的设置会使生成的wuftp格式的日志存到/var/log/vsftpd.log文件中。当然,你也可以更改xferlog_file=/xxx/xxx来选择其它的目录文件。这样你生成的vsftpd.log日志格式将是下面的样子:  
Sun May 23 08:34:27 2004 67 192.168.1.100 975291 /lastlog a _ o a -anonymous@ ftp 0 * c  
Sun May 23 08:34:28 2004 68 192.168.1.101975291 /lastlog a _ o a -anonymous@ ftp 0 * c  
Sun May 23 08:34:28 2004 68 192.168.1.102 975291 /lastlog a _ o a -anonymous@ ftp 0 * c
2.4.2.    配置一个生成vsftpd日志统计的awstats配置文件
 cd /usr/local/awstats/tool
 perl awstats_configure.pl
 根据提示在/etc/awstats下生成vsftpd的配置文件,这里假设生成下awstats.vsftpd.conf
 编辑生成文件:
   vi  /etc/awstats.vsftpd.conf
LogFile="/var/log/vsftplog"
LogFormat="%time3 %other %host %bytesd %url %other %other %method %other %logname %other %code %other %other"
LogSeparator="\s"
SiteDomain="vsftpd”
HostAliases="vsftpd 127.0.0.1 localhost"
DNSLookup=0
DirData="/var/lib/awstats"
DirCgi="/awstats"
DirIcons="/awstatsicons"
AllowToUpdateStatsFromBrowser=0
NotPageList=""  
LevelForBrowsersDetection=0  
LevelForOSDetection=0  
LevelForRefererAnalyze=0  
LevelForRobotsDetection=0  
LevelForWormsDetection=0  
LevelForSearchEnginesDetection=0  
ShowLinksOnUrl=0  
ShowMenu=1  
ShowMonthStats=UVHB  
ShowDaysOfMonthStats=HB  
ShowDaysOfWeekStats=HB  
ShowHoursStats=HB  
ShowDomainsStats=HB  
ShowHostsStats=HBL  
ShowAuthenticatedUsers=HBL  
ShowRobotsStats=0  
ShowEMailSenders=0  
ShowEMailReceivers=0  
ShowSessionsStats=1  
ShowPagesStats=PBEX  
ShowFileTypesStats=HB  
ShowFileSizesStats=0  
ShowBrowsersStats=0  
ShowOSStats=0  
ShowOriginStats=0  
ShowKeyphrasesStats=0  
ShowKeywordsStats=0  
ShowMiscStats=0  
ShowHTTPErrorsStats=0  
ShowSMTPErrorsStats=0
2.4.3.    生成统计页面
 cd /usr/local/awstats/ wwwroot/cgi-bin
 ./awstats.pl –update –config=/etc/awstats/awstats.vsftpd.conf
打开页面:
  查看生成的统计数据.


阅读(2596) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~