Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2266971
  • 博文数量: 168
  • 博客积分: 6641
  • 博客等级: 准将
  • 技术积分: 1996
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-02 11:49
文章存档

2020年(4)

2019年(6)

2017年(1)

2016年(3)

2015年(3)

2014年(8)

2013年(2)

2012年(12)

2011年(19)

2010年(10)

2009年(3)

2008年(17)

2007年(80)

分类: LINUX

2010-11-23 23:03:08

使用Awstats统计Vsftpd访问日志
 
2010.11.23 TsengYia#126.com  http://tsengyia.blog.chinaunix.net/
 
####################################################################

系统环境:RHEL5.5 [ 2.6.18-194.el5 ]
软件环境:
    httpd-2.2.3-43.el5
    vsftpd-2.0.5-16.el5_4.1
    awstats-7.0.tar.gz
        ——

####################################################################
一、解压部署awstats
[root@localhost ~]# tar zxf awstats-7.0.tar.gz
[root@localhost ~]# mv awstats-7.0 /usr/local/

[root@localhost ~]# mkdir /var/lib/awstats        #//创建数据目录
 

二、为FTP站点创建日志统计配置文件
 
1.创建站点配置文件
[root@localhost ~]# cd /usr/local/awstats/
[root@localhost awstats]# tools/awstats_configure.pl        #//运行配置向导工具
……
Enter full config file path of your Web server.
> /etc/httpd/conf/httpd.conf        #//指定Apache服务器的配置文件路径
……
Do you want to build a new AWStats config/profile
file (reuired if first install) [y/N] ? y        #//确认创建新的站点配置文件
……
What is the name of your web site or profile analysis ?
Your web site, virtual server or profile name:
>         #//要统计的站点名称
……
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):
> /etc/awstats        #//指定配置文件的存放目录,可直接回车接受默认值
……
-----> Create config file '/etc/awstats/awstats.ftp.tsengyia.com.conf'
 Config file /etc/awstats/awstats.ftp.tsengyia.com.conf created.
……
Press ENTER to continue...
……
You can then manually update your statistics for 'ftp.tsengyia.com' with command:
> perl awstats.pl -update -config=ftp.tsengyia.com
You can also read your statistics for 'ftp.tsengyia.com' with URL:
>
Press ENTER to finish...
[root@localhost ~]#
 
2. 修改站点配置文件
[root@localhost ~]# vi /etc/awstats/awstats.ftp.tsengyia.com.conf
……
LogFile="/var/log/vsftpd.log"        #//确认vsftpd访问日志文件的位置
LogType=F        #//设置日志类型,FTP对应为F,Web服务对应为W,Mail对应为M
LogFormat="%time3 %other %host %bytesd %url %other %other %method %other %logname %other %
code %other %other"        #//设置自定义的日志格式,对应xferlog_std_format
LogSeparator="\s"
DNSLookup=0
……
 

三、调整vsftpd服务配置
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf
……
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
……
[root@localhost ~]# /etc/init.d/vsftpd reload
 

四、更新日志统计信息
[root@localhost ~]# cd /usr/local/awstats/wwwroot/cgi-bin/
[root@localhost cgi-bin]# ./awstats.pl -update -config=ftp.tsengyia.com
 
[root@localhost ~]# crontab -e
*/5 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=ftp.tsengyia.com
 
[root@localhost ~]# /etc/init.d/crond start
[root@localhost ~]# chkconfig --level 35 crond on
 

五、从浏览器访问测试
 
1.生成日志记录(如果原日志记录的格式符合要求,可跳过此步)
[root@localhost ~]# :> /var/log/vsftpd.log        #//清空旧有日志记录
[root@localhost ~]# ftp server_ip
……        #//访问FTP服务器并进行下载操作
 
2.创建站点统计页,启动httpd服务
[root@localhost ~]# vi /var/www/html/ftpstat.html





 
[root@localhost ~]# /etc/init.d/httpd start
[root@localhost ~]# chkconfig --level 35 httpd on
 
    在网页浏览器中访问 即可查看统计信息。
阅读(2410) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~