1.解压并释放awstats软件包,执行目录中的awstats_configure.pl脚本进行安装
[root@test src]# tar zxvf awstats-7.1.tar.gz -C /usr/local/
[root@test src]# mv /usr/local/awstats-7.1/ /usr/local/awstats
[root@test src]# cd /usr/local/awstats/tools/
[root@test tools]# ./awstats_configure.pl
(1)选择“y”,将httpd服务的日志记录格式改为“combined”,以便记录更多详细信息。
-----> Check and complete web server config file '/usr/local/apache2/conf/httpd.conf'
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ? y
(2)选择“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
(3)定义日志分析的目标网站名称(如:www.benet.com)
-----> 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:
> www.sn.com
(4)定义awstats配置文件的存放目录(默认为“/etc/awstats”)
-----> 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):
>
(5)添加cron计划任务(安装脚本无法自动添加,提示用户需手动添加,按回国键继续)。
-----> 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.sn.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...
(6)按回车键退出安装脚本
A SIMPLE config file has been created: /etc/awstats/awstats.www.sn.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.sn.com' with command:
> perl awstats.pl -update -config=www.sn.com
You can also read your statistics for 'www.sn.com' with URL:
> http://localhost/awstats/awstats.pl?config=www.sn.com
Press ENTER to finish...
2.修改awstats.www.benet.conf配置文件
[root@test conf]# vi /etc/awstats/awstats.www.sn.com.conf
LogFile="/usr/local/apache2/logs/sn.access.log"
3.创建数据库存放目录,并更新数据库
[root@test conf]# mkdir /var/lib/awstats
[root@test conf]# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update-config=
www.sn.com
4.设置cron计划任务,以便定时运行日志分析程序
[root@test conf]# crontab -e
* */5 * * * perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.sn.com
[root@test logs]# service crond start
[root@test logs]# chkconfig --level 35 crond on
5.访问网址:http://www.sn.com/awstats/awstats.pl?config=www.sn.com
6.访问控制:基于用户的访问控制
(1)在httpd.conf里添加如下行
<Directory "/usr/local/awstats/wwwroot">
......
AuthName "AWSTATS"
AuthType Basic
AuthUserFile /usr/local/awstats/wwwroot/.htpasswd
require valid-user
</Directory>
(2)用htpasswd命令创建用户帐户“awuser”,并保存为.htpasswd文件,-c 表示新建谁文件,当向已有的认证文件中添加账号时可以省略“-c”选项。
[root@test bin]# cd /usr/local/apache2/bin/
[root@test bin]# ./htpasswd -c /usr/local/awstats/wwwroot/.htpasswd awuser
New password:
Re-type new password:
7.基于客户端地址的访问控制
Order allow,deny:先允许后拒绝,默认拒绝所有没有被明确允许的客户端地址。
Order deny,allow:先拒绝后允许,默认允许所有没有被明确拒绝的客户端地址。