下载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. Maven使用第三方jar文件的两种方法 转

    在Maven中,使用第三方库一般是通过pom.xml文件中定义的dependency从远程repository中下载该库.但是如果库文件是公司内部的库,或者在本地而不能通过远程repository下载 ...

  2. xml基础小结

    XML基础 1)XML的作用 1.1 作为软件配置文件 1.2 作为小型的“数据库” 2)XML语法(由w3c组织规定的) 标签: 标签名不能以数字开头,中间不能有空格,区分大小写.有且仅有一个根标签 ...

  3. 是否以某字符串结尾 是否以某字符串开始 是否是整数 裁减字符串空格 是否是浮点数 是否所有字符为数字类型 是否为空 是否是EMAIL 是否是电话号码 身份证号码验证-支持新的带x身份证 日期验证

    /* 1.是否以某字符串结尾 endsWith(theStr,endStr) @param theStr:要判断的字符串 @param endStr:以此字符串结尾 @return boolean; ...

  4. Decode Ways -- LeetCode

    原题链接: http://oj.leetcode.com/problems/decode-ways/  这道题要求解一个数字串依照字符串编码方式可解析方式的数量.看到这样的求数量的,我们非常easy想 ...

  5. Java 线程第三版 第一章Thread导论、 第二章Thread的创建与管理读书笔记

    第一章 Thread导论 为何要用Thread ? 非堵塞I/O      I/O多路技术      轮询(polling)      信号 警告(Alarm)和定时器(Timer) 独立的任务(Ta ...

  6. HTTP 404 - 未找到文件 怎么样解决

    找不到网页  您要查看的网页可能已被删除.名称已被更改,或者临时不可用.  -------------------------------------------------------------- ...

  7. android 66 sharedperference的使用

    package com.itheima.qqlogin; import java.io.BufferedReader; import java.io.File; import java.io.File ...

  8. Makefile详解--隐含规则

    Makefile详解--隐含规则(转) Makefile系列文章,这里有个前辈连续洗了一个系列来介绍,共有26篇博客文章. http://www.cppblog.com/ivenher/archive ...

  9. request对象

    Servlet三大域对象的应用 request.session.application(ServletContext) 请求转发器: public void doGet(HttpServletRequ ...

  10. Windows系统下搭建Jenkins环境

    1. 安装JDK JDK下载地址:  http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.ht ...