设为首页 收藏本站
查看: 1670|回复: 0

[经验分享] 日志分析软件awstats的安装使用指南

[复制链接]

尚未签到

发表于 2017-5-21 12:07:25 | 显示全部楼层 |阅读模式
  1. 下载地址


     http://sourceforge.net/projects/awstats/  

    

     http://voxel.dl.sourceforge.net/sourceforge/awstats/awstats-6.4-1.noarch.rpm

2. 安装    

     2.1 rpm安装


[iyunv@web tools]# rpm -ivh awstats-6.4-1.noarch.rpm  

Preparing...                  ########################################### [100%]

     1:awstats                  ########################################### [100%]


----- AWStats 6.4 - Laurent Destailleur -----

AWStats files have been installed in /usr/local/awstats


If first install, follow instructions in documentation

(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:

Step 1 : Install and Setup with awstats_configure.pl (or manually)

Step 2 : Build/Update Statistics with awstats.pl

Step 3 : Read Statistics

    

     2.2 tar包安装

    

         直接解压就行了,因为awstats是由perl编写的。其实都一样。

        

3. 运行配置脚本生成awstats的配置文件

     cd /usr/local/awstats/tools

     perl awstats_configure.pl  

     配置脚本询问域名等问题,假设回答的域名为www.abcd.com

     3.1 生成的配置文件会放在/etc/awstats/下面

     3.2 生成的配置文件的名称为awstats.www.adcd.com.conf

     3.3 配置脚本只能修改主要的log日志为combined,如果设置了虚拟主机,需要分别修改虚拟主机中的日志配置。

         格式设置 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

          自定义的日志采用什么格式 CustomLog logs/testmysite-access_log combined

          创建日志 TransferLog logs/testmysite-access_log

         

4. 编辑awstats.www.abcd.com.conf,保证awstats的正常运行


     4.1 设置web server的logfile位置

         编辑LogFile为web server的log文件位置

         LogFile=/usr/local/apache2/logs/abcd-access_log

         一定保证和httpd.conf中的log文件保证一致,httpd.conf中log名称为

         logs/abcd-access_log

     4.2 设置要分析的服务日志类型

         LogType=W   

         w表示为WEB日志

     4.3 设置日志格式

         LogFormat=1  

         1表示采用NCSA apache combined/ELF/XLF log format

     4.4 设置所要分析网站域名

         SiteDomain="www.testmysite.com.cn"

         引号中一定要填上域名,或者服务器主机名

     4.5 设置awstats的数据库存放目录

         DirData="/usr/local/awstats/data"

    

5. 创建awstats初始化数据库


     perl awstats.pl -config=www.abcd.com -update  

    

6. 创建awstats的初始化静态统计页面


     perl awstats.pl -config=bbs.testmysite.com.cn -output -staticlinks > awstats.bbs.html  

    

7. 通过浏览器刷新统计页面


     7.1 修改awstats.www.testmysite.com.cn.conf中

         AllowToUpdateStatsFromBrowser=1

     7.2 修改awstats的存放数据目录的属性为apache的运行用户可读写

         chown -R nobody /usr/local/awstats/data

     7.3 检查/usr/local/awstats/wwwroot/cgi-bin/*.pl 是否有执行权限

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

        

         注:rpm安装包里面的*.pl都具有执行权限,tar包里面的*.pl却没有。

        


8. 设置需要认证才能访问流量统计页面


     8.1 设置用户admin有权访问该页面

         cd /usr/local/apache2/bin

         ./htpasswd    -c /usr/local/apache2/passwords admin

         按提示连续输入两次密码,这样就创建了admin用户才能访问流量统计页面。

        

     8.2 设置httpd.conf中的awstats条目增加如下内容

             AuthType Basic

             AuthName "Restricted Files"

             AuthUserFile /usr/local/apache2/passwords

             Require user admin

            

9. 两种观看日志分析方法的比较

    

     9.1 静态页面分析方法的优点

         a. 安全性高,因为分析过程可以在后台通过crontab来执行,不需要执行cgi.

         b. 统计分析页面响应速度快,因为是自动生成的静态页面,所以速度快过动态生成的页面。

         c. 对服务器的负载影响可控,自动生成的脚本执行次数一定,对服务器的负载影响也是一定的。

     9.2 动态页面分析方法的优点

         a. 实时查看,可以随时在页面动态刷新统计分析结果。

        

     9.3 上面两种方法的缺点就是他们优点的反面。

    

10. awstats在apache虚拟主机下的配置     

        

     10.1 虚拟主机有3个

          www.testmysite.com.cn

          bbs.testmysite.com.cn

          diy.testmysite.com.cn

     10.2 生成并修改对应虚拟主机的配置文件

    

          cd /etc/awstats

          cp awstats.www.testmysite.com.cn.conf awstats.bbs.testmysite.com.cn.conf

          cp awstats.www.testmysite.com.cn.conf awstats.diy.testmysite.com.cn.conf

     10.3 修改配置文件中的下列各项   

          LogFile=/usr/local/apache2/logs/bbs-accesss_log

          修改为实际的虚拟主机的log文件位置

          SiteDomain="bbs.testmysite.com.cn"

          修改为实际各虚拟主机的域名

     10.4 修改httpd.conf各虚拟主机中的配置

          <VirtualHost 202.108.59.23>

          。。。。。。

          CustomLog logs/testmysite-access_log combined

          TransferLog logs/testmysite-access_log

          。。。。。。

          </VirtualHost>  

          主要是修改日志格式保证apache输出的日志格式和awstats配置文件中配置一致。

12. 观看流量统计方法


      12.1 用户名&密码

           admin/testmysiteok

      12.2 在浏览器输入

          

           查看主页流量分析

           http://www.testmysite.com.cn/awstats/awstats.pl?config=www.testmysite.com.cn

           查看bbs流量分析

           http://www.testmysite.com.cn/awstats/awstats.pl?config=bbs.testmysite.com.cn

           查看diy流量分析

           http://www.testmysite.com.cn/awstats/awstats.pl?config=diy.testmysite.com.cn

          

           为了便于使用可以将以上连接加入收藏夹。
  问题:awstats and selinux
  I have been futzing with this problem all day. I installed "awstats" to

start getting better stats on my web server usage. It worked like a

charm on my test box but failed on my production box. After looking too

long in the wrong places I finally found the problem. It is selinux.


Symptoms were, when I attempted to look at the awstats page, which is a

perl script, I got the following in my Apache error_log:


...(13)Permission denied: exec of

'/usr/local/awstats/wwwroot/cgi-bin/awstats.pl' failed

...Premature end of script headers: awstats.pl



I checked all of the permissions of everything and everything was right.

Finally I found a post that mentioned looking for errors

in /var/log/messages. I look there for other things I don't know I never

thought to look there for this. Anyway, when I looked there I saw:



...kernel: audit(1146243585.213:27): avc: denied { execute } for

pid=20973 comm="httpd" name="awstats.pl" dev=dm-0 ino=1082675

scontext=root:system_r:httpd_t tcontext=system_u:object_r:usr_t

tclass=file



I turned off selinux with the "setenforce 0
" command and it started

working.


Now, the problem here is that I really do not want to run my production

server without selinux turned on and was not able to figure out how to

correct the conflict. Anybody that could offer a pointer in the right

direction will be my new best friend :)

配置都没有问题了。只有只读属性我想是linux中的selinux引起的,你关掉试试好了。
关闭SELinux的方法:
修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
如果不想重启系统,使用命令setenforce 0
注:
setenforce 1 设置SELinux 成为enforcing模式
setenforce 0 设置SELinux 成为permissive模式
在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux 。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-379575-1-1.html 上篇帖子: WEB日志分析利器Awstats安装使用 下篇帖子: Awstats 多個 log 的顯示方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表