awstats安装配置

1. 下载awstats
http://www.awstats.org/

2.解压缩到 D:\awstats-7.4

3、初始化配置环境
进入 D:\awstats-7.4\tools
   执行 awstats_configure.pl文件
D:\awstats-7.4\tools>perl awstats_configure.pl

4、输入 Apache Web目录
Apache Web server path ('none' to skip):
>D:\Apache22

5、输入 httpd.conf的目录

Now, enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):

>D:\Apache22\conf\httpd.conf

6、然后无需建立新conf,选N 按回车两次

-----> Check and complete web server config file 'D:\Apache22\conf\httpd.conf'
  Add 'Alias /awstatsclasses "../wwwroot/classes/"'
  Add 'Alias /awstatscss "../wwwroot/css/"'
  Add 'Alias /awstatsicons "../wwwroot/icon/"'
  Add 'ScriptAlias /awstats/ "../wwwroot/cgi-bin/"'
  Add '<Directory>' directive
  AWStats directives added to Apache config file.

-----> Update model config file '..\wwwroot\cgi-bin\awstats.model.conf'
  File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ?n

7、在 httpd.conf自动增加了以下内容:

#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "../wwwroot/classes/"
Alias /awstatscss "../wwwroot/css/"
Alias /awstatsicons "../wwwroot/icon/"
ScriptAlias /awstats/ "../wwwroot/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "../wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

8、修改D:\awstats-7.4\wwwroot\cgi-bin中的awstats.pl
将#!/usr/bin/perl
改为
#!D:/Perl/bin/perl.exe

9、D:\awstats-7.4\wwwroot\cgi-bin中复制awstats.model.conf更改为awstats.www.dzh.com.conf

LogType=W
Lang="auto"更新为 Lang="cn"
SiteDomain="www.dzh.com"
AllowToUpdateStatsFromBrowser=0更为AllowToUpdateStatsFromBrowser=1

10、更改apache的httpd.conf配置文件
D:\Apache22\conf\httpd.conf
将 CustomLog "logs/access.log" common
更改为
CustomLog "|bin/rotatelogs.exe D:/Apache22/logs/access-%y%m%d.log 86400 480" combined

D:\Apache22\conf\extra\httpd-vhosts.conf
将 CustomLog "logs/access.log" common
更改为
CustomLog "|bin/rotatelogs.exe D:/Apache22/logs/access-%y%m%d.log 86400 480" combined

11、配置完成,重启apache

输入http://127.0.0.1:80/awstats/awstats.pl?config=www.dzh.com 提示
Forbidden

You don't have permission to access /awstats/awstats.pl on this server.
12 、更改httpd.conf
<Directory "../wwwroot">
   
Options None
   
AllowOverride None
 
Order allow,deny
 
Allow from all

</Directory>

 

更改为
<Directory "/awstats-7.4/wwwroot">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

Alias /awstatsclasses "../wwwroot/classes/"
Alias /awstatscss "../wwwroot/css/"
Alias /awstatsicons "../wwwroot/icon/"
ScriptAlias /awstats/ "../wwwroot/cgi-bin/"
更改为

Alias /awstatsclasses "/awstats-7.4/wwwroot/classes/"
Alias /awstatscss "/awstats-7.4/wwwroot/css/"
Alias /awstatsicons "/awstats-7.4/wwwroot/icon/"
ScriptAlias /awstats/ "/awstats-7.4/wwwroot/cgi-bin/"

13、重启apache, OK
http://127.0.0.1/awstats/awstats.pl?config=www.dzh.com 显示
 
统计网站:
www.dzh.com

摘要
按参观时间:
按月历史统计
按日期统计
按星期
每小时浏览次数
按参观者:
国家或地区

14、http://127.0.0.100/awstats/awstats.pl?config=www.dzh.com 也ok

15、安全设置httpd.conf中输入更改
<Directory "/awstats-7.4/wwwroot">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
  
    AuthType Basic
    AuthName "duanzhihua"
    AuthUserFile C:/AWStats/wwwroot/cgi-bin/.passwd
    Require valid-user require

</Directory>

16、进入apache,D:\Apache22\bin
执行htpasswd.exe生成用户名密码

htpasswd.exe -c D:/awstats-7.4/wwwroot/cgi-bin/.passwd duanzhihua

输入密码

D:\awstats-7.4\tools>cd D:\Apache22\bin

D:\Apache22\bin>htpasswd.exe -c D:/awstats-7.4/wwwroot/cgi-bin/.passwd duanzhihu
a
New password: ******
Re-type new password: ******

17、在D:\awstats-7.4\wwwroot\cgi-bin多了一个密码文件 .passwd

18、重启apache

再次打开
http://127.0.0.1/awstats/awstats.pl?config=www.dzh.com

输入用户名密码报错
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@example.com and inform them of the time the error occurred, and

anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

检查日志
127.0.0.1 - duanzhihua [20/Sep/2015:21:51:19 +0800] "GET /awstats/awstats.pl?config=www.dzh.com HTTP/1.1" 500

537 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130

Safari/537.36"

[Sun Sep 20 21:51:19 2015] [error] [client 127.0.0.1] (OS 3)系统找不到指定的路径。  : Could not open password

file: C:/AWStats/wwwroot/cgi-bin/.passwd

19.之前httpd。conf中的路径配错了
将AuthUserFile C:/AWStats/wwwroot/cgi-bin/.passwd
更改为AuthUserFile D:/AWStats/wwwroot/cgi-bin/.passwd

20 重启
打开http://127.0.0.1/awstats/awstats.pl?config=www.dzh.com

报错
[Sun Sep 20 21:58:28 2015] [error] [client 127.0.0.1] (OS 3)系统找不到指定的路径。  : Could not open password

file: D:/AWStats/wwwroot/cgi-bin/.passwd
 

21将
D:/AWStats/wwwroot/cgi-bin/.passwd
改为
D:\awstats-7.4\wwwroot\cgi-bin\.passwd

21重启测试

打开http://127.0.0.1/awstats/awstats.pl?config=www.dzh.com

输入用户名密码

一切OK