[iyunv@server awstats]# cd tools/
[iyunv@server tools]# ls
awstats_buildstaticpages.pl awstats_updateall.pl maillogconvert.pl xslt
awstats_configure.pl httpd_conf urlaliasbuilder.pl
awstats_exportlib.pl logresolvemerge.pl webmin
[iyunv@server tools]# perl awstats_configure.pl
----- AWStats awstats_configure 1.0 (build 1.7) (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):
# 输入apache配置文件路径
> /etc/httpd/conf/httpd.conf
-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.
# 是否需要为网站配置一个新的配置文件(选y)
-----> 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:
# 为你的站点起个名字
> tech
-----> 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):
# 默认配置文件的存放位置(直接回车,使用默认的即可/etc/awstats)
>
-----> Create config file '/etc/awstats/awstats.tech.conf'
Config file /etc/awstats/awstats.tech.conf created.
-----> 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=tech
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...
A SIMPLE config file has been created: /etc/awstats/awstats.tech.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'tech' with command:
> perl awstats.pl -update -config=tech
You can also read your statistics for 'tech' with URL:
# 这是查看此站点分析结果的页面
> http://localhost/awstats/awstats.pl?config=tech
Press ENTER to finish...
# 检查apache的配置文件,如果awstats的配置没有自动加入配置文件则进行下面的步骤。
# 拷贝awstats的配置文件到apache配置文件的包含目录下,或者将httpd_conf的内容直接加到apache配置文件的最后
[iyunv@server tools]# cp httpd_conf /etc/httpd/conf.d/awstats.conf
# awstats的配置文件较旧,修要做些修改
[iyunv@server tools]# vi /etc/httpd/conf.d/awstats.conf
# 加入标红的内容
# Content of this file, with correct values, can be automatically added to
# your Apache server by using the AWStats configure.pl tool.
#
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path "/usr/local/awstats/" must reflect your AWStats install path.
#
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/"
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot/cgi-bin">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
LogFormat=1
使用apache的combined格式的日志。
SiteDomain=”tech”
站点名称。
HostAliases=”localhost 127.0.0.1 REGEX[tech\.com$]”
如果站点有其它的域名的话也可以在这里加进来,也一并计算入内。
DirData=”/var/lib/awstats”
指定存放数据文件的目录,默认是/var/lib/awstats,注意该目录需要运行脚本的用户有写入权限。awstats默认按照月来存放文件,也就是说每个月一个文件。(注意要使用绝对路径)
该配置文件中还有很多选项,可以做一些细微的调节或者添加插件等。
接下来是要对日志进行分析,运行命令:
[iyunv@server wwwroot]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=tech -update
Create/Update database for config "/etc/awstats/awstats.tech.conf" by AWStats version 6.7 (build 1.892)
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: 307
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 307 new qualified records.
可以将上面命令加入cron任务,定时进行分析。