一直想找个工具分析一下有些什么人来参观我的blog,经过朋友推荐,决定使用AWStats。
官方网站:http://awstats.sourceforge.net
安装平台:红旗 DC Server 5.0 for x86
一、安装
安装还是比较简单的,先下载,然后编译即可:
wget http://internap.dl.sourceforge.net/sourceforge/awstats/awstats-6.5.tar.gz
cd awstats-6.5
make
make install
安装结束提示信息有:
#
# 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
也就是他要你修改apache的配置文件,加入上面的几句。这里可以不用手动增加,后面用命令也可以。
AWStats软件主要文件安装在 /usr/local/awstats 目录下。
二、准备
要使用AWStats,必须搞清楚几个地方:
1、你使用的Apache配置文件在那里?
红旗DC Server 5.0默认是放在/etc/httpd/conf/httpd.conf
2、根据要求修改日志记录方式,记录它的文件和路径
因为AWStats是靠分析apache的日志文件来生成数据的,所以必须修改日志的记录方式为它所使用的方式。
在httpd.conf文件中加入:
修改apache的Log方式:
如果你使用的是虚拟主机方式,则可以修改虚拟主机设置中的CustomLog,如:
ServerName www.test.com
DocumentRoot /usr/local/www/test
CustomLog /var/log/test_access_log combined
ErrorLog /var/log/test_error_log
最后重启apache。
※注意,如果你以前有旧格式的日志文件,最好删掉它,等待自动生成新格式的日志文件
三、生成配置文件
使用AWStats自带的awstats_configure.pl命令:
./awstats_configure.pl
根据提示提供apache的配置文件路径;提供配置文件的名字;其他默认即可。
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:Program filesapache groupapacheconfhttpd.conf
Config file path (‘none’ to skip web server setup):
> /etc/httpd/conf/httpd.conf
—–> Check and complete web server config file ‘/etc/httpd/conf/httpd.conf’
AWStats directives already present.
—–> 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
—–> 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:
> test
—–> 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):
>
—–> Create config file ‘/etc/awstats/awstats.rfgz.conf’
Config file /etc/awstats/awstats.test.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/www/awstats/wwwroot/cgi-bin/awstats.pl -update -config=rfgz
Or if you have several config files and prefer having only one command:
/usr/local/www/awstats/tools/awstats_updateall.pl now
Press ENTER to continue…
A SIMPLE config file has been created: /etc/awstats/awstats.rfgz.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘test’ with command:
> perl awstats.pl -update -config=test
You can also read your statistics for ‘test’ with URL:
> http://localhost/awstats/awstats.pl?config=test
Press ENTER to finish…
生成的配置文件在/etc/awstats下,名字类似awstats.test.conf。通常我们可以再进行修改:
DirData=”/var/lib/awstats”
四、生成AWStats数据,并查看
使用下面的命令让AWStats分析日志:
若是有多个配置文件,则可以执行:
生成的数据库默认放在:/var/lib/awstats/下。
访问地址: