欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

awstats安装配置文档 里面的关键是有关于多个虚拟主机的配置

shiping1 的头像

来自 http://88fly.blog.163.com/blog/static/1226803902013842193482/
awstats安装配置文档
  

2013-09-04 14:19:34|  分类: opensoft |  标签:log  awstats   |举报 |字号 订阅

 
                                   
 
 
l awstats官方网站
 
下载地址
 
示例地址
 
测试地址
 
l 安装步骤
环境
Perl+apache+php(此处yum安装)
tar -zxvf awstats-7.2.tar.gz
mv awstats-7.2 /usr/local/awstats
/usr/local/awstats/tools
perl awstats_configure.pl
#注:awstats-7.2.tar.gz包内的perl文件默认是没有可执行权限的,需先给予可执行权限
chmod –R 775 /usr/local/awstats/tools
 
 
----- AWStats awstats_configure 1.0 (build 1.9) (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
 
-----> 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):
> /etc/httpd/conf/httpd.conf   #检测出您的apache的httpd.conf,根据实际情况定义
 
-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
  Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'
  Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'
  Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'
  Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'
  Add '<Directory>' directive
  AWStats directives added to Apache config file.
 
-----> Update model config file '/usr/local/awstats/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] ? y         #创建config文件
 
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: demo
Your web site, virtual server or profile name:
> www.a.com   #输入您的网站域名:(主要是为了区别服务器上多个网站的设置文件)
 
-----> 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):
> (是否将config文件,保存在默认的文件夹 /etc/awstats 下,回车继续)
 
-----> Create config file '/etc/awstats/awstats.www.a.com.conf'
 Config file /etc/awstats/awstats.www.a.com.conf created.
 
-----> Restart Web server with '/sbin/service httpd restart'
停止 httpd:                                               [确定]
启动 httpd:                                               [确定]
 
-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.a.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue... /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.a.com
A SIMPLE config file has been created: /etc/awstats/awstats.www.a.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.a.com' with command:
> perl awstats.pl -update -config=www.a.com
You can also read your statistics for 'www.a.com' with URL:
 
Press ENTER to finish...
 
按回车来结束安装 ,接下来的工作就是
执行perl awstats.pl -update -config=s1.domain1.com来更新数据库
#由于要不断的更新得到最新的数据,故要不断执行如上更新数据库操作,也就是分析日志提取里面新增的部分进行分析,将更新的数据存入数据库的过程
 
 
 
l 配置修改
 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.bestunix.net    HostAliases 主机别名     
  
AllowToUpdateStatsFromBrowser  
  下面这项是是否允许从浏览器里更新统计文件,默认是0不允许,如果我们改为1的话,就需要apache的属主用户对/var/lib/awstats目录有读写权限,并对/var/log/httpd目录有读取权限  
     
  AllowFullYearView  
这个不用修改默认值。awstats默认是以月为单位进行日志分析,如果我们要分析整年的日志的可以在
这里设置,因为分析整年的日志的话可能要消耗很多系统资源。如果你需要对年日志进行分析的话,建议手工启动。   
  
 实际修改内容
  LogFile="/usr/local/apache/logs/access_log"     (多access_log被切割为多个文件 此处可用access_log*)
AllowToUpdateStatsFromBrowser=1 
 
注意:生成的日志分析结果的保存路径配置文件中默认为DirData="/var/lib/awstats" 默认是没有的需自行创建并给予可执行权限,也可改变其路径
mkdir –p /var/lib/awstats
Chmod 775 /var/lib/awstats
 
重启apache服务
 
更新数据库
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.a.com
 
 
l 更新数据库常见问题
 
1.存放分析数据文件(/var/lib/awstats)不存在
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.infowarelab.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
解决方法
mkdir –p /var/lib/awstats
Chmod 775 /var/lib/awstats
 
 
2.日志文件格式不正确,或者之前的日志文件格式不正确
Create/Update database for config "/etc/awstats/awstats.www.a.com.conf" by AWStats version 7.2 (build 1.992)
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...
AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log.
Your log file /var/log/httpd/access_log must have a bad format or LogFormat parameter setup does not match this format.
 
解决方法
vi /usr/local/apache/conf/httpd.conf 
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog logs/access_log combined 
检查 是否为combined类型 
检查 是否在awstats的config文件中设置了正确的apache日志路径  
检查 是否做了Alias解析 
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/" 
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/" 
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"   
如果以上两项皆正确,删除以前的日志文件,重启apache 
 
Your AWStats LogFormat parameter is:
1
This means each line in your web server log file need to have "combined log format" like this:
111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] "GET / HTTP/1.1" 200 1234 "http://www.fromserver.com/from.htm" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
And this is an example of records AWStats found in your log file (the record number 50 in your log):
60.173.10.101 - - [26/Aug/2013:16:21:40 +0800] "GET /cas/login.action?service=http%3A%2F%2F202.91.242.53%2Fmeeting%2Fapp%2Fmeetinglist%2FtodayDataList.action%3Fsite%3Dbox%26menuname%3D24000_24001_24002&site=box&gateway=true HTTP/1.1" 302 0 - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; MASP)"
Setup ('/etc/awstats/awstats.www.a.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
 
3.Log权限问题
Error: Couldn't open server log file "/var/log/httpd/access_log" : Permission denied 
 
Setup ('/etc/awstats/awstats.www.a.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory). 
 
解决方法
chmod 775 
/var/log/httpd/access_log
 
 
 
 
10.在浏览器中通过一下地址进入awstats统计页面。 
awstats安装配置文档 - herb - herb
 
 
 
l 多虚拟主机配置
例如虚拟主机
bbs.a.com
diy.a。com
cd /etc/awstats 
cp awstats.www.a.com.con.conf awstats.bbs.a.com.conf 
cp awstats.www.a.com.con.conf awstats.diy.a.com conf 
修改配置文件中(各个awstats.*.conf的文件)的下列各项   
  LogFile=/usr/local/apache2/logs/bbs-accesss_log 
   修改为实际的虚拟主机的log文件位置 
   SiteDomain="bbs.a.com       
 修改为实际各虚拟主机的域名 
   修改httpd.conf各虚拟主机中的配置 
        <VirtualHost 172.16.0.23> 
 
        CustomLog logs/access_log combined 
 
        </VirtualHost>  
 
修改访问链接即可
 
 
l 访问页面常见问题
1. 访问出错
 
 
You don’t have permission to access /awstats/awstats.pl on this server
解决办法
Chomod 775 /usr/local/awstats/wwwroot/cgi-bin/awstats.pl
 
 
2.首页点击立即更新
Error: Couldn't open server log file "/var/log/httpd/access_log" : Permission denied 
 
Setup ('/etc/awstats/awstats.www.a.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
解决办法
普通分类: