一、安装apache(省略)
二、安装配置awstats
把下载好的安装包解压,然后把解压出来的文件放到安装路径如:/usr/local,重命名为awstats然后开始安装
cd awstats/tools/
perl awstats_configure.pl
 以下内容为安装过程:
 
----- 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配置文件路径)
 
-----> 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     选择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:
> www.ifind.com       为统计对象创建代号(推荐以网站URL作为代号)
 
-----> 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):
>     (直接按回车,接受将Awstats的配置文件置于/etc/awstats)
 
-----> Create config file '/etc/awstats/awstats.www.ifind.com.conf'
 Config file /etc/awstats/awstats.www.ifind.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.ifind.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...
(按回车继续进行配置)
 
A SIMPLE config file has been created: /etc/awstats/awstats.www.ifind.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.ifind.com' with command:
> perl awstats.pl -update -config=www.ifind.com
You can also read your statistics for 'www.ifind.com' with URL:
> http://localhost/awstats/awstats.pl?config=www.ifind.com
 
Press ENTER to finish...    (按回车结束初始配置)
 
 
然后对刚刚创建的对象配置文件进行配置。
vi /etc/awstats/awstats.www.ifind.com
LogFile="/var/log/httpd/mylog.log" 找到这一行,修改日至文件所在位置

LogFormat=1       设置要分析的日志类型
1 - Apache or Lotus Notes/Domino native combined log format (NCSA combined/XLF/ELF log format)
2 - IIS or ISA format (IIS W3C log format). See FAQ-COM115 For ISA.
3 - Webstar native log format.
4 - Apache or Squid native common log format (NCSA common/CLF log format)
 
DirData="/var/lib/awstats"  找到这一行,更改Awstats数据的保存位置
 
Lang="auto"    设置显示语言,默认为简体中文
接下来,再对httpd.conf中面向Awstats的部分进行确定。
vi /etc/httpd/conf/httpd.conf
看看是否有以下内容
----------------------------------------------------
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/"
----------------------------------------------------
<Directory "/usr/local/awstats/wwwroot">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>    可以配置访问权限
重新启动HTTP服务,使设置生效
 
 
 
配置完毕后,我们可以通过各种适用于自己的方式,定义统计的方式以及输出的结果。
1,创建一个脚本vi /root/awstats.sh 
 
  要关闭selinux
 
2,然后在客户端的浏览器上访问 http://服务器IP地址(或你的域名)/awstats/awstats.pl?config=即可看到详细的分析统计资料,如下图:www.ifind.com
完成以上配置,我们已经可以通过客户端的浏览器,掌握Web服务器的访问量、来路等等详细的信息,但由于Awstats的统计是基于Apache日志的, 我们必须通过awstats.pl对当前最新的日志文件进行统计才能得到最新的统计结果。也就是说,在我们运行自行创建的awstats.sh脚本之前, 当前在客户端能够看到的统计分析结果,只是上一次运行awstats.sh脚本时统计的结果。想得到最新的统计结果,必须再次运行awstats.sh。 在这里,我们将其设置为每天定时自动运行,以便于每天都能查看到最新的信息。如下:0 0 * * * /root/awstats.sh