awstats_yum_dnf_centos8_nginx

awstats_yum_dnf_centos8_nginx

转载注明来源: 本文链接 来自osnosn的博客,写于 2020-05-26.

参考:
AWStats Other utilities
AWStats简介
还有另外一个日志分析工具叫 GoAccess

安装,用 yum 或 dnf

  • dnf install awstats
    centos8中,安装的是 7.7 版

修改 /etc/awstats/awstats.localhost.localdomain.conf

  • 读取多个log文件。
    LogFile="/usr/share/awstats/tools/logresolvemerge.pl /var/log/nginx/access.log /var/log/nginx/ssl.access.log |"
  • SiteDomain="12.34.56.78" 或者写上你的域名。
  • 按需修改
    • HostAliases="localhost 127.0.0.1"
    • SkipHosts="127.0.0.1"
    • SkipFiles=""
  • 改名 mv awstats.localhost.localdomain.conf awstats.12.34.56.78.conf
  • /etc/awstats/awstats.model.conf 这个文件不要动,只是个模板。awstats实际读取配置文件时,会忽略这个文件名。

生成静态文件

  • 用 crontab 执行 03 03 * * * /usr/share/awstats/tools/awstats_buildstaticpages.pl -config=12.34.56.78 -lang=cn2 -awstatsprog=/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -dir=/your_web_path/html/stat/awstats/

    我的nginx documentroot=/your_web_path/html

  • 上一行中,可以用-lang=en
  • -lang=cn的话,生成的html是gbk编码的。改 utf-8
    • cd /usr/share/awstats/lang/ , iconv -f gbk -t utf-8 awstats-cn.txt > awstats-cn2.txt ,
      然后修改 awstats-cn2.txt 的第一行 PageCode=GBKPageCode=UTF-8 即可。

nginx 配置,访问 awstats 的静态文件。

location /awstatsicons/ {
   alias   /usr/share/awstats/wwwroot/icon/;
}

location ^~ /stat/ {
   # 如果需要账号保护
   # auth_basic  "admin";
   # auth_basic_user_file   $document_root/stat/.htaccess.pw ;
   include /etc/nginx/default.d/php.conf;

   location /stat/awstats/classes/ {
      alias   /usr/share/awstats/wwwroot/classes/;
   }
   location /stat/awstats/css/ {
      alias   /usr/share/awstats/wwwroot/css/;
   }
   location /stat/awstats/js/ {
      alias   /usr/share/awstats/wwwroot/js/;
   }
}

访问 http://12.34.56.78/stat/awstats/awstats.12.34.56.78.html 就能看到了。

不生成静态文件。直接配置nginx的动态页面。

  • 我没配置。请自行搜索方法。

转载注明来源: 本文链接 来自osnosn的博客.

猜你喜欢

转载自www.cnblogs.com/osnosn/p/12969260.html