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

[经验分享] awstats+nginx 安装配置

[复制链接]
累计签到:8 天
连续签到:1 天
发表于 2015-11-27 14:22:02 | 显示全部楼层 |阅读模式
wget http://awstats.sourceforge.net/files/awstats-7.0.tar.gz
tar -zxvf awstats-7.0.tar.gz
mv awstats-7.0 /usr/local/awstats
chown -R root:root /usr/local/awstats
chmod -R =rwX /usr/local/awstats
chmod +x /usr/local/awstats/tools/*.pl
chmod +x /usr/local/awstats/wwwroot/cgi-bin/*.pl
cd /usr/local/awstats/tools
./awstats_configure.pl
#现在进入配置文件,按照下面的输入
#  none  (我这里是nginx 不是apache,所以是none)
#  y    (创建新的一个配置文件)
#  firefoxbug  (基于什么域名)
#  
#A SIMPLE config file has been created: /etc/awstats/awstats.firefoxbug.conf
#You should have a look inside to check and change manually main parameters.
#You can then manually update your statistics for 'firefoxbug' with command:
#> perl awstats.pl -update -config=firefoxbug
#You can also build static report pages for 'firefoxbug' with command:
#> perl awstats.pl -output=pagetype -config=firefoxbug
#-----> Create config file '/etc/awstats/awstats.firefoxbug.conf'
#                 Config file /etc/awstats/awstats.firefoxbug.conf create
  


  以上步骤默认会产生配置文件 ==>> /etc/awstats/awstats.firefoxbug.conf
  awstats 配置文件的命名规则:awstats.website.conf
  修改配置文件
  

# vim /etc/awstats/awstats.firefoxbug.conf
#  LogFile="/var/log/httpd/mylog.log" ==>>  LogFile="/path/to/you_website_log_path"
  
  创建awstats统计结果的数据库存放目录
  

mkdir -p /var/lib/awstats
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=firefoxbug
  



awstats.pl 会去读取-config中的参数,把 firefoxbug 扩展成 awstats.firefoxbug.conf 去 /etc/awstats 目录或者当期目录下搜索,根据读取到的配置文件运行程序。  分析日志:运行后将这样的日志统计结果归档到一个AWStats的数据库(纯文本)里;

然后是输出:分两种形式

               1. 一种是通过cgi程序读取统计结果数据库输出;

               2. 一种是运行后台脚本将输出导出成静态文件;

  统计分析完成后,结果还在 Awstats 的数据库中。在 Apache 上,可以直接打开 Perl 程序的网页查看统计。 但Nginx 对 Perl 支持并不好,所以要换个方法,利用 awstats 的工具将统计的结果生成静态文件,具体的步骤如下:



先生成存放awstats生成的静态文件的目录,我这里用的是/var/www/HduISA/awstats



  

mkdir /var/www/HduISA/awstats
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update  -config=firefoxbug -lang=cn -dir=/var/www/HduISA/awstats/firefoxbug
  


  awstats_buildstaticpages.pl 会根据 -config 的参数去读取里面的 DirData 路径下数据库配置文件,然后生成静态的html文件,生成的文件重定向到/var/www/HduISA/awstats/firefoxbug。
  最后是nginx的配置文件,根据自己路径配置
  

server {
listen       80;
server_name  localhost;
root /var/www/HduISA;
index index.html;
location ~ ^/awstats/ {     # awstats  静态页面目录
root   /var/www/HduISA/awstats
autoindex on; #可以目录浏览你的多个域名的目录用于分析
index  index.html;
access_log off;
}
location ~ ^/icon/ {             # 图标目录
root   /usr/local/awstats/wwwroot;
index  index.html;
access_log off;
}
}
  




查看 www.your_website.com/awstats/xxx.html


  


运维网声明 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-144167-1-1.html 上篇帖子: 利用awstats分析tomcat日志 下篇帖子: awstats+google chart
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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