deer2010 发表于 2015-11-27 14:22:02

awstats+nginx 安装配置

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_namelocalhost;
root /var/www/HduISA;
index index.html;
location ~ ^/awstats/ {   # awstats静态页面目录
root   /var/www/HduISA/awstats
autoindex on; #可以目录浏览你的多个域名的目录用于分析
indexindex.html;
access_log off;
}
location ~ ^/icon/ {             # 图标目录
root   /usr/local/awstats/wwwroot;
indexindex.html;
access_log off;
}
}
  




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


  

页: [1]
查看完整版本: awstats+nginx 安装配置