免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1162 | 回复: 0
打印 上一主题 下一主题

freebsd7.0 awstats [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-01-08 14:31 |只看该作者 |倒序浏览

环境freebsd7.0  awstats 6.6-1
cd /usr/ports/www/awstats-devel
make install clean;rehash


#装完后的提示:
Please add the following to your apache config, and restart.
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses “/usr/local/www/awstats/classes/”
Alias /awstatscss “/usr/local/www/awstats/css/”
Alias /awstatsicons “/usr/local/www/awstats/icons/”
ScriptAlias /awstats/ “/usr/local/www/awstats/cgi-bin/”
#
# This is to permit URL access to scripts/files in AWStats directory.
#
Options None
AllowOverride None
Order allow,deny
Allow from all
*****************************************************************
If you are upgrading from AWStats 6.4 or older, please note the following:
If you used the geoip plugin, you must edit your AWStats config file
to change the line
LoadPlugin=”geoip GEOIP_STANDARD”
into
LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat”
3.配置awstats
#复制配置模板(并按需修改配置模板)
mkdir /etc/awstats
cp /usr/local/www/awstats/cgi-bin/awstats.model.conf /etc/awstats/
#生成配置文件
/usr/local/www/awstats/tools/awstats_configure.pl
#Do you want to continue setup from this NON standard directory
y
#Check for web server install
#询问apache配置路径(/usr/local/etc/apache22/httpd.conf),若输入了会追加以下信息,直接输入 none 跳过
#把以下内容保存到加入到虚拟主机的配置中
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses “/usr/local/www/awstats/classes/”
Alias /awstatscss “/usr/local/www/awstats/css/”
Alias /awstatsicons “/usr/local/www/awstats/icons/”
ScriptAlias /awstats/ “/usr/local/www/awstats/cgi-bin/”
#
# This is to permit URL access to scripts/files in AWStats directory.
#
Options None
AllowOverride None
Order allow,deny
Allow from all

配置例子
Alias /awstatsclasses "/home/www/awstats/classes/" // 将“/usr/local/www/”改为自定义的“/usr/home/www/”
Alias /awstatscss "/home/www/awstats/css/"
Alias /awstatsicons "/home/www/awstats/icons/"
ScriptAlias /awstats/ "/home/www/awstats/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
           Options None
           AllowOverride None
           Order allow,deny
           Allow from all


# Need to create a new config file ?
y
#Define config file name to create
test.jluzh.com

#Define config file path
#直接使用回车使用默认(保存到/etc/awstats/awstats.www.mydomain.com.conf
#修改配置:
vi /etc/awstats/awstats.www.mydomain.com.conf
#修改日志路径
LogFile=”/www/mydomain.com/logs/%YYYY-24/%MM-24/%DD-24.log”
注意#修改日志apache的日志记录 这里监测成功的记录 ,大家可以按照上面重新设置apache的日志记录 ,日志设置错误没图形出来的
可以用命令测试一下
/usr/local/www/awstats/cgi-bin/awstats.pl -update -config=test.jluzh.com
一般出现如下的结果就正常
Create/Update database for config "/etc/awstats/awstats.test.jluzh.com.conf" by AWStats version 6.6 (build 1.885)
From data in log file "/var/log/httpd-access.log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 228
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 228 new qualified records.
LogFile=”/var/log/httpd-access.log“
#日志分析结果
DirData=”/etc/awstats”
#HostAliases,去掉 127.0.0.1 localhost
HostAliases=”mydomain.com www.mydomain.com”
#配置apache日志记录格式:我 没有配置apache的日志记录
CustomLog “|/usr/local/sbin/cronolog /www/mydomain.com/logs/%Y/%m/%d.log” combined
#激活apache配置:
/usr/local/etc/rc.d/apache22 graceful
#访问一次http://www.mydomain.com 以生成新的日志
#执行awstats(会提示找不到前一天的日志,如:/www/mydomain.com/logs/2007/04/10.log,touch一个空文件再执行即可):
/usr/local/www/awstats/tools/awstats_updateall.pl now

#查看分析页面:
http://mydomain/awstats/awstats.pl?config=www.mydomain.com
在crontab里添加
50 * * * * root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.youdomains.com

大家可以用htpasswd 添加用户,我这台机器安装svn的时候添加了密码,密码放在/etc/svnuser
#直接在里面添加相应部分就ok了!
########################################################################
其中也走了不了少弯路,出现wwwroot的那种情况大家可以参考这里
http://www.servertechnology.cn/archives/858.html
现在的最新版本6.6已经发布正式版本。如果你的ports里的版本小于6.6,那么一定要更新ports至最新版本。因为以前的版本有漏洞。
#cd /usr/ports/www/awstats-devel
#make install
(注,如果下载不下来,可以用wget下载至/usr/ports/distfiles里面。)
#wget
http://jaist.dl.sourceforge.net/sourceforge/awstats/awstats-6.6.tar.gz
安装完毕后会有一段提示
*****************************************************************
Please add the following to your apache config, and restart.
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses “/usr/local/www/awstats/classes/”
Alias /awstatscss “/usr/local/www/awstats/css/”
Alias /awstatsicons “/usr/local/www/awstats/icons/”
ScriptAlias /awstats/ “/usr/local/www/awstats/cgi-bin/”
#
# This is to permit URL access to scripts/files in AWStats directory.
#
Options None
AllowOverride None
Order allow,deny
Allow from all
*****************************************************************
If you are upgrading from AWStats 6.4 or older, please note the following:
If you used the geoip plugin, you must edit your AWStats config file
to change the line
LoadPlugin=”geoip GEOIP_STANDARD”
into
LoadPlugin=”geoip GEOIP_STANDARD /pathto/GeoIP.dat”
*****************************************************************
===> Registering installation for awstats-6.6_1,1
awstats要求将http.conf中的CustomLog /yourlogpath/yourlogfile common 改为
CustomLog /yourlogpath/yourlogfile combined ,我看了一下,我默认的就是combined,可能现在新版本默认的都是这个吧,那就不用改了。
再进入/usr/local/www/awstats/tools里,运行./awstats_configure.pl启动安装向导,步骤如下
----- AWStats awstats_configure 1.0 (build 1.6) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
—–> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is ‘/usr/local/awstats’.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/usr/local/www/awstats
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ?
y
-----> Check for web server install
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):
>
输入你httpd.conf的路径。对于httpd2系列的一般都在/etc/httpd/conf/这个目录下面
这里将awstats的配置信息直接写入了httpd.conf
-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
Add 'Alias /awstatsclasses "/usr/local/www/awstats/wwwroot/classes/"'
Add 'Alias /awstatscss "/usr/local/www/awstats/wwwroot/css/"'
Add 'Alias /awstatsicons "/usr/local/www/awstats/wwwroot/icon/"'
Add 'ScriptAlias /awstats/ "/usr/local/www/awstats/wwwroot/cgi-bin/"'
Add '‘ directive
AWStats directives added to Apache config file.
—–> 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] ?
创建一个配置文件,选Y
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example:
www.mysite.com
Example: demo
Your web site, virtual server or profile name:
下面是要生成conf文件的名称了,因为conf文件的名称都是awstats.yourdomainname.conf格式的,所以这里要求你输入你要监测的域名,其实这个域名只是与其他域名相区分的,并不一定非要真实的。
-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
这里是让你输入配置文件的路径,直接回车会执行默认的,当然你也可以自己定义
剩下的工作我们就需要手工完成了。
第一, 在crontab里手工加进去
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.youdomains.com,因为这个程序是通过分析日志来进行流量统计的,如果你的日志文件很大的话是很耗系统资源的。还好,我的流量不大,我设定的是每个小时运行一次,你如果服务器比较繁忙的话也可以每天夜里运行一次。当然你也可以手工运行上面的命令来进行更新统计信息。
第二,conf文件的配置:
LogFile
指定你要分析的日志文件,默认是/var/log/httpd/mylog.log,可以根据你的需要调整,如果你要分析httpd的全部日志的就是/var/log/httpd/access_log,我们一般就选这个了。
LogType
log类型,默认是web log,不用修改,如果你不是的话就自己照说明改了。
LogFormat
log格式,一般情况下如果是apache的话就是1,iis就是2,默认不用修改,你也可以照说明自定义,呵呵,我还不太清楚怎么定义。
LogSeparator
log中的分隔符,默认不用修改,如果上面的格式是你自定义的话这里也要修改了
DNSLookup
默认不用修改
DirData
生成的日志分析结果的保存路径,默认是/var/lib/awstats,你如果要使用默认的路径的话,这个目录是需要手工创建的,注意这个路径必须是可读写的。
下面四项都是在配置时,不用修改。
DirCgi cgi的路径,这里都是相对于网站根目录的绝对路径
DirIcons icon的路径
SiteDomain 域名:
www.youdomains.com
HostAliases 主机别名
AllowToUpdateStatsFromBrowser
下面这项是是否允许从浏览器里更新统计文件,默认是0不允许,如果我们改为1的话,就需要apache的属主用户对/var/lib/awstats目录有读写权限,并对/var/log/httpd目录有读取权限
AllowFullYearView
这个不用修改默认值。awstats默认是以月为单位进行日志分析,如果我们要分析整年的日志的可以在这里设置,因为分析整年的日志的话可能要消耗很多系统资源。如果你需要对年日志进行分析的话,建议手工启动。
这样最基本的配置就完成了,我们可以通过
http://www.youdomains.com
awstats/awstats.pl?config=www.youdomains.com来查看统计信息。
常见问题:
[root@demo conf.d]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.bestunix.net
Error: AWStats database directory defined in config file by 'DirData' parameter (/var/lib/awstats) does not exist or is not writable.
Setup ('/etc/awstats/awstats.www.youdomains.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
这个是因为在/etc/awstats/awstats.www.youdomains.com.conf中DirData中定义的目录启动apache的用户没有写得权限,更改目录或更改权限都可以解决。
问题二,出来的页面里所有的流量统计都是空的。
同样是/etc/awstats/awstats.www.youdomains.com.conf的问题,在这个文件里有一行
LogFile=”/var/log/httpd/mylog.log”
我们一般情况下把这个路径改为”/var/log/apache/access.log”就可以了,如果你设了很多虚拟主机,每个主机都配置了不同的log的话,在这里指定你要统计的那个主机的log文件就可以了。
问题三,浏览页面时提示没有权限,出现403错误,给上wwwroot目录权限755就OK了
注:默认的awstats目录结构里并没有wwwroot。可以自己加上去。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/57953/showart_459605.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP