安装 awstats
 

# unzip awstats-7.0.zip -d /usr/local/

 
# cd /usr/local/

 
# mv awstats-7.0/ awstats

 
# cd /usr/local/awstats/tools/

# ./awstats_configure.pl
 

 
# ./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
Found Web server Apache config file '/etc/httpd/httpd.conf'

-----> Check and complete web server config file '/etc/httpd/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
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

-----> 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.test.com
……
之后两次回车即可


修改http配置文件

CustomLog "logs/access_log" combined

http-2.4的访问控制和以前不一样的,改成Require all granted即可
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Require all granted
</Directory>

修改# vim /etc/awstats/awstats.192.168.80.139.conf的如下内容,要和http的配置文件中的一样
LogFile="/usr/local/apache/logs/access_log"
 


 
生成库文件
 
# mkdir /var/lib/awstats
 

# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com
 


 
设置个任务计划
 

# crontab -e
*/5 * * * * /usr/bin/perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.peace.com
 


 
生成文件
 
# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com -output -staticlinks > /usr/local/apache/htdocs/awstats.html

 
之后通过浏览器访问http://www.test.com/awstats.html即可