Saturday, September 17, 2011

安装和配置 JAWStats

JAWStats 是基于 Awstats 统计数据的,但其界面更为强悍,有了JAWStats 你甚至可以抛弃第三方统计了。

2.1. 下载与安装

1
2
3
4
5
wget http://static.jawstats.com/src/jawstats-0.7beta.tar.gz
mkdir /var/www/stats/
tar -zxf jawstats-0.7beta.tar.gz -C /var/www/stats/
cd /var/www/stats/
cp config.dist.php config.php

2.2. 修改配置文件

官方配置说明见:http://www.jawstats.com/documentation
jawstats 是支持多站点的,每个 $aConfig 对应一个站点,并可以自由切换。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
// core config parameters
$sDefaultLanguage = "zh-cn"; // 设置默认语言
$sConfigDefaultView = "thismonth.all";
$bConfigChangeSites = false; //是否可以更换站点
$bConfigUpdateSites = false; //是否可以更新统计数据
$sUpdateSiteFilename = "xml_update.php";
 
// individual site configuration
$aConfig["site1"] = array( // site1 网站域名(注意不能乱填)
"statspath" => "/var/lib/awstats/", //awstats 统计数据目录
"updatepath" => "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl/", //用于更新统计数据
"siteurl" => "http://wangyan.org", //点击首页标题后会前往这个地址
"sitename" => "wangyan.org", //首页标题
"theme" => "default",
"fadespeed" => 250,
"password" => "my-1st-password", //更新统计数据需要输入这个密码
"includes" => "",
"language" => "zh-cn"
);
?>

 1 <?php
  2
  3   // core config parameters
  4   $sDefaultLanguage      = "ch-tw";
  5   $sConfigDefaultView    = "thismonth.all";
  6   $bConfigChangeSites    = true;
  7   $bConfigUpdateSites    = true;
  8   $sUpdateSiteFilename   = "xml_update.php";
  9
 10   // individual site configuration
 11   $aConfig["www1"] = array(
 12     "statspath"   => "/var/lib/awstats/",
 13     "updatepath"  => "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl/",
 14     "siteurl"     => "http://www.wcjs.tcc.edu.tw",
 15     "sitename"    => "wcjs",
 16     "theme"       => "default",
 17     "fadespeed"   => 250,
 18     "password"    => "my-1st-password",
 19     "includes"    => "",
 20     "language"    => "ch-tw"
 21   );
 22
 23   $aConfig["site2"] = array(
 24     "statspath"   => "/path/to/data/",
 25     "updatepath"  => "/path/to/awstats.pl/",
 26     "siteurl"     => "http://www.my-2nd-domain.com",
 27     "sitename"    => "",
 28     "theme"       => "default",
 29     "fadespeed"   => 250,
 30     "password"    => "my-2nd-password",
 31     "includes"    => "",
 32     "language"    => "ch-tw"
 33   );
 34
 35 ?>
 

 

2.3. 安装中文语言包

首先下载 jawstats 多国语言包,解压缩后上传替换 lang 目录。
http://www.jawstats.com/src/languagepack.zip
需要注意的是,你要修改 translations.php 文件的编码为UTF-8,不然全乱码了。
另外修改汉化文件,也是translations.php,不能只修改zh-cn.js文件。

2.4. 设置JAWStats访问密码

Nginx 支持为目录添加密码认证,若不想所有人都能访问到你的统计结果,那继续下面步骤吧。。。
1) 使用apache 的 htpasswd 来创建密码文件。
1
语法:htpasswd -b -c /home/wangyan/.htpasswds 用户名 密码
2) 在Nginx的server字段内添加以下内容
1
2
3
4
5
6
7
8
9
10
11
location ~ /stats {
root /var/www;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
auth_basic "JAWStats";
auth_basic_user_file /home/wangyan/.htpasswds;
}
最后大功告成,输入 https://youdomain/stats/ 便可以访问了。HomeAny source

No comments:

Post a Comment