下载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. 小物件之radio单选列表

    有时候在控制器中做了一个数组 然后需要在模板view中循环 同时还需要判断是否有选中的值,就会造成很多开始闭合标签 以前都是这样写 这样实在太繁琐了,不如封装一个小物件 封装函数如下: 代码如下: f ...

  2. nginx查看进程连接信息

    linux 中查看当前请求连接的进程统计信息 root@VM-24-181-ubuntu:/# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) ...

  3. DDoS deflate - Linux下防御/减轻DDOS攻击

    2010年04月19日 上午 | 作者:VPS侦探 前言 互联网如同现实社会一样充满钩心斗角,网站被DDOS也成为站长最头疼的事.在没有硬防的情况下,寻找软件代替是最直接的方法,比如用iptables ...

  4. java方法的重载

    java方法的重载 public class Person1 {    private String name; //姓名    private int age;      //年龄    priva ...

  5. 深入了解当前ETL中用到的一些基本技术

    数据集成是把不同来源.格式和特点的数据在逻辑上或物理上有机地集中,从而为企业提供全面的数据共享,是企业商务智能.数据仓库系统的重要组成部分.ETL是企业数据集成的概念出发,简要分析了当前ETL中用到的 ...

  6. Android-Unable to resolve target 'android-8'

  7. 移动測试技术保护源码!解码全球首款移动端白盒測试工具ThreadingTest (文章转自己主动点科技)

    作者 智晓锋 - 2014/07/14 自从斯诺登曝光美监听丑闻事件之后,我国政府就将信息安全问题上升到了国家安全的高度.基于此.国内的一家创业公司推出了智能型Android真机白盒測试以及开发辅助类 ...

  8. Android(java)学习笔记194:ListView编写步骤(重点)

    1.ListView在我们的手机android编写程序中使用是十分广泛的,比如如下图中 短信 和 手机设置 都是ListView的效果: 手机设置:             短信:    2.正因为这 ...

  9. Customize the SharePoint 2013 search experience with a Content Enrichment web service

    Did you ever wish you had more control over how your content is indexed and presented as search resu ...

  10. 让Sql语句区分大小写

    除非你使用 LIKE 来比较字符串,否则MySQL的WHERE子句的字符串比较是不区分大小写的. 你可以使用 BINARY 关键字来设定WHERE子句的字符串比较是区分大小写的. SELECT * f ...