下载awstats最新安装包并解压

cd /usr/local/src
wget http://www.awstats.org/files/awstats-7.3.tar.gz

tar -zxvf awstats-7.3.tar.gz

把awstats解压目录更名及把需要用到的pl文件提高到可执行权限、创建需要用到的文件夹:

mv awstats-7.3 awstats

mv awstats /usr/local/

chmod +x /usr/local/awstats/tools/awstats_configure.pl

chmod +x /usr/local/awstats/wwwroot/cgi-bin/awstats.pl

chmod +x /usr/local/awstats/tools/awstats_buildstaticpages.pl

# 这里是用来存放 AWStats 的数据库文件的
mkdir /var/lib/awstats

新建 awstats 配置文件(运行前查看perl版本是否安装)

perl /usr/local/awstats/tools/awstats_configure.pl
-----> 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 files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
#> none #因为我们这里用的是 Nginx,所以写 none,跳过。

回车

Your web server config file(s) could not be found.
You will need to setup your web server manually to declare AWStats
script as a CGI, if you want to build reports dynamically.
See AWStats setup documentation (file docs/index.html) -----> 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 创建一个新的统计配置

回车

-----> 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.moabc.net #统计网站的域名

回车

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

使用默认直接回车,接下来便会出现以下的提示

----> 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.moabc.net
#回头把该命令填入crontab 按指定时间执行
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... 回车继续 A SIMPLE config file has been created: /etc/awstats/awstats.www.moabc.net.conf
#新配置文件所在的路径
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.moabc.net' with command:
> perl awstats.pl -update -config=www.moabc.net
You can also build static report pages for 'www.moabc.net' with command:
> perl awstats.pl -output=pagetype -config=www.moabc.net Press ENTER to finish...

回车完成向导,接下来修改 www.moabc.net 的统计配置

vi /etc/awstats/awstats.www.moabc.net.conf

找到统计的日志文件的路径

LogFile="/var/log/httpd/mylog.log"

改为

LogFile="/usr/local/tengine/logs/access_%YYYY-0%MM-0%DD-0.log

对应上边 Nginx 日志切割程序的所生成的目录存放结构,要注意 Awstats 的年月日格式的跟 Nginx 的写法有所不同。我们现在执行统计的顺序是:

Nginx 产生日志 –> 日志切割 –> Nginx 继续产生日志 –> 另存切割日志 –> 交由Awstats统计 –> 生成结果

在本文中 Awstats 所统计的日志,是已切下来的那部分。也能调转顺序,先统计完了再切。不过这比较容易造成统计的遗漏。配置修改完成后,保存退出。然后我们可以开始试一下手动执行。

创建切割日志脚本:

vi /usr/local/tengine/sbin/log_cut.sh

#!/bin/bash
# 这里根据你自己的文件名来写 mv /usr/local/tengine/logs/access.log /usr/local/tengine/logs/access_$(date -d "today" +"%Y%m%d").log #这里时tengine的pid存放目录
kill -USR1 `cat /usr/local/tengine/logs/nginx.pid`

保存

设置可执行权限:

chmod +x /usr/local/tengine/sbin/log_cut.sh

可以试一下运行:

/usr/local/tengine/sbin/log_cut.sh

新建要生成 HTML 报告的目录,把图片和CSS复制进去

mkdir -p /usr/local/tengine/html/awstats/

cp -R /usr/local/awstats/wwwroot/css /usr/local/tengine/html/awstats/

cp -R /usr/local/awstats/wwwroot/icon /usr/local/tengine/html/awstats/

生成 awstats 数据库:

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.moabc.net #这里 -config=www.moabc.net 意思是说使用 /etc/awstats/awstats.www.moabc.net.conf 这个文件

生成 AWStats 日志分析报告

/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.moabc.net -lang=cn -dir=/usr/local/tengine/html/awstats/ awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl

配置tengine页面访问认证

通过使用apache的创建认证文件工具创建

htpasswd -c /usr/local/tengine/sbin/pd mike

如果没用可以用网上的认证工具生成验证账户和密码(如:http://www.4webhelp.net/us/password.php)

vi /usr/local/tengine/sbin/pd

mike:79y.NuPCo1CqU

保存

再tengine配置文件server主机中添加http访问增加一下代码:

location /awstats {
charset gbk;
access_log off;
root /usr/local/tengine/html;
       index index.html index.htm;
       auth_basic "awstats login";
       auth_basic_user_file /usr/local/tengine/sbin/pd;
}

 location /icon {
        charset gbk;
        access_log off;
        root /usr/local/tengine/html/awstats;
        index index.html index.htm;
}

 

至此浏览器打开可以看到分析结果页面了

接下来配置分析日志定时任务

crontab -e

  * * - /bin/bash /usr/local/tengine/sbin/log_cut.sh
* * - /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.moabc.net -lang=cn -dir=/usr/local/tengine/html/awstats/ awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl

设置成了每天晚上11点执行切割tengine日志,每天网上11点30分执行更新awstats分析日志生成静态分析日志结果html文档到目录。

awstats中文关键字乱码

修改awstats的配置文件

在使用centos/redhat系统的rpm包安装的awstats的配置路径为/etc/awstats下。打开所要统计网站的配置文件awstats.xxxxx.conf,将下面一行的#去掉:

LoadPlugin="decodeutfkeys"

不过打开这个plugin 需要perl模块儿Encode和URI::Escape的支持,一般情况下perl是默认支持的。

如果打开AWStats会显示:

Error: Plugin load for plugin 'decodeutfkeys' failed with return code: Error: Can't locate URI/Escape.pm in @INC (@INC contains: /usr/lib/perl5/5.8.7/i686-linux /usr/lib/perl5/5.8.7 /usr/lib/perl5/site_perl/5.8.7/i686-linux  /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl . ./lib ./plugins) at (eval 4) line 1.

這是因為缺少 Perl 的 URI:Escape模块

下载安装URI:Escape模块:

cd /usr/local/src

wget http://www.cpan.org/authors/id/G/GA/GAAS/URI-1.60.tar.gz

tar -zxvf URI-1.60.tar.gz

cd URI-1.60

perl Makefile.PL

make

make install

然后再更新下awstats重新更新tengine日志

/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.moabc.net -lang=cn -dir=/usr/local/tengine/html/awstats/ awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl

刷新下页面关键字乱码就正常了。

完毕。

使用awstats统计分析tengine日志访问量及各种http网站数据的更多相关文章

  1. 烂泥:利用awstats分析nginx日志

    本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb 昨天把nginx的日志进行了切割,关于如何切割nginx日志,可以查看<烂泥:切割 ...

  2. linux服务器上nginx日志访问量统计命令

    linux服务器上nginx日志访问量统计命令 日志文件所在地方:/var/log/nginx/access_iqueendress.com.log/var/log/nginx/access_m.iq ...

  3. 使用awstats分析nginx日志

    1.awstats介绍 本文主要是记录centos6.5下安装配置awstats,并统计nginx访问日志 1.1 awstats介绍 awstats是一款日志统计工具,它使用Perl语言编写,可统计 ...

  4. tengine日志切割-配置分钟级别日志自动切割

    tengine日志切割-配置分钟级别日志自动切割 安装 以安装最新版本的tengine-2.1.2版本 下载连接 tengine支持许多变量 变量 $conn_requests 当前请求在长连接上的序 ...

  5. 【慕课网实战】八、以慕课网日志分析为例 进入大数据 Spark SQL 的世界

    用户行为日志:用户每次访问网站时所有的行为数据(访问.浏览.搜索.点击...)     用户行为轨迹.流量日志   日志数据内容: 1)访问的系统属性: 操作系统.浏览器等等 2)访问特征:点击的ur ...

  6. 如何使用 Python 统计分析 access 日志?

    一.前言 性能场景中的业务模型建立是性能测试工作中非常重要的一部分.而在我们真实的项目中,业务模型跟线上的业务模型不一样的情况实在是太多了.原因可能多种多样,这些原因大大降低了性能测试的价值. 今天的 ...

  7. Awstats分析Nginx日志

    1.nginx日志格式设定 log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$ ...

  8. Nginx配置Awstats分析Nginx日志笔记

    1.修改Nginx日志格式: log_format json '$remote_addr - $remote_user [$time_local] "$request" '     ...

  9. lograte切割tengine日志

    记录 /srv/logs/nginx/*log { create 0644 nobody nobody daily rotate 10 missingok notifempty compress sh ...

随机推荐

  1. 深入理解Objective-C:优化你的代码

    开篇 只要用到Objective-C,我们每天都会跟方法调用打交道.我们都知道Objective-C的方法决议是动态的,但是在底层一个方法究竟是怎么找到的,方法缓存又是怎么运作的却鲜为人知. 本文主要 ...

  2. FM笔记

    1.获取生产订单状态 CALL FUNCTION 'STATUS_TEXT_EDIT' EXPORTING client = sy-mandt objnr = p_objnr spras = sy-l ...

  3. 在内核外编写的linux驱动程序MAKEFILE

    一般都是这么写: ifneq ($(KERNELRELEASE),) obj-m :=  else KERNELDIR ?= /lib/modules/$(shell uname -r)/build ...

  4. Java IO流学习总结(转)

    Java流操作有关的类或接口: Java流类图结构: 流的概念和作用 流是一组有顺序的,有起点和终点的字节集合,是对数据传输的总称或抽象.即数据在两设备间的传输称为流,流的本质是数据传输,根据数据传输 ...

  5. android 69 SQLite数据库

    package com.itheima.sqlitedatabase; import java.sql.ResultSet; import android.content.Context; impor ...

  6. vxworks

    VxWorks 是美国 Wind River System 公司( 以下简称风河公司 ,即 WRS 公司)推出的一个实时操作系统.Tornado 是WRS 公司推出的一套实时操作系统开发环境,类似Mi ...

  7. CentOS6.5一键安装MySQL5.5.32(源码编译)

    ###################################################mysql_install.sh                                 ...

  8. safe_mode(php安全模式)

    简单说,PHP安全模式就是以安全模式运行php. php的安全模式提供一个基本安全的共享环境,在一个有多个用户帐户存在的php开放的web服务器上.当一个web服务器上运行的php打开了安全模式,那么 ...

  9. JS获取URL的参数

    function request(paras) { var url = location.href; , url.length).split("&"); var paraO ...

  10. sql查询最大id

    如 有个表里有字段 id,name,..... 当name是重复时取其id最大的一条记录 select max(id) id,name from 表 group by name --最小用mini - ...