参考博文:

http://freeloda.blog.51cto.com/2033581/1346412

http://freeloda.blog.51cto.com/2033581/1346076

http://www.shuijingwanwq.com/2013/07/30/82/

http://os.51cto.com/art/201311/415087_all.htm

1、安装apache

yum -y install gcc gcc-c++ openssl-devel pcre-develtar  xf  apr-1.4.6.tar.bz2cd apr-1.4.6./configure --prefix=/usr/local/apr --disable-ipv6make && make installtar xf apr-util-1.4.1.tar.bz2cd apr-util-1.4.1./configure  --prefix=/usr/local/apr-util  --with-apr=/usr/local/aprmake && make installtar zxf httpd-2.4.17.tar.gz cd httpd-2.4.17./configure \--prefix=/usr/local/apache \--sysconfdir=/etc/httpd \--enable-so \--enable-ssl \--enable-cgi \--enable-rewrite \--with-zlib \--with-pcre \--with-apr=/usr/local/apr \--with-apr-util=/usr/local/apr-util \--enable-modules=most \--enable-mods-shared=most \--enable-mpms-shared=all \--with-mpm=eventmake && make installcp build/rpm/httpd.init /etc/init.d/httpdvim /etc/init.d/httpd    httpd=${HTTPD-/usr/local/apache/bin/httpd}    pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}    lockfile=${LOCKFILE-/var/lock/subsys/${prog}}    RETVAL=0    # check for 1.3 configuration    check13 () {        CONFFILE=/etc/httpd/httpd.confecho "PATH=/usr/local/apache/bin:$PATH" >> /etc/profile.d/http.sh. /etc/profile.d/http.shln -s /usr/local/apache/include/ /usr/include/httpdvim /etc/httpd/httpd.conf    ServerName localhost:80chkconfig --add httpdchkconfig httpd onservice httpd start

2、安装日志切割工具cronolog

wget http://cronolog.org/download/cronolog-1.6.2.tar.gztar xf cronolog-1.6.2.tar.gzcd cronolog-1.6.2./configuremake && make installvim /usr/local/httpd/httpd.conf    CustomLog "|/usr/local/sbin/cronolog /log/www/access_%Y%m%d.log"mkdir -p /log/wwwchmod -R 755 /log/www/  chown -R daemon /log/www/

3、安装awstats

tar zxf awstats-7.4.tar.gz mv awstats-7.4 /usr/local/awstatscd /usr/local/awstats/chown -R root.root /usr/local/awstatschmod +x /usr/local/awstats/wwwroot/cgi-bin/*.plcd /usr/local/awstats/tools/ ./awstats_configure.pl    > perl awstats.pl -update -config=www.test.com vim /etc/awstats/awstats.www.test.com.conf     LogFile="/log/www/access_%YYYY-24%MM-24%DD-24.log"  #日志文件存放路径,其中%YYYY-24%MM-24%DD是指年月日模式    DirData="/var/lib/awstats"  #创建生成的数据路径    Lang="cn"  #默认语言中文    SkipHosts="127.0.0.1 REGEX[^192\.168\.]" #本地及内部的访问不做分析统计    LevelForWormsDetection=2  #日志等级,不对警告日志进行统计mkdir -pv /var/lib/awstats chmod 755 /var/lib/awstats/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.comvim /etc/httpd/httpd.conf    
        LoadModule cgid_module modules/mod_cgid.so        
        Options None        AllowOverride None        Require all granted        Order allow,deny        Allow from 192.168.100.1    service httpd restart

4、设置定时生成静态awstat数据

crontab -u root -e5 0 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com

5、测试

在浏览器中输入网址

http://www.test.com/awstats/awstats.pl?config=www.test.com