(1)下载awstats-6.95.zip。然后将其解压到/usr/local目录中

  1. [root@localhost tmp]# unzip awstats-6.95.zip -d /usr/local

(2)进入/usr/local目录中,并给awstats-6.95创建链接文件awstats。

  1. [root@localhost tmp]# cd /usr/local  
  2. [root@localhost local]# ln -sv awstats-6.95/ awstats  
  3. [root@localhost local]# ll  
  4. total 112  
  5. drwxr-xr-x 13 root root 4096 Jun  1 09:29 apache  
  6. lrwxrwxrwx  1 root root   13 Jul  5 18:22 awstats -> awstats-6.95/  /链接文件创建好  
  7. drwxr-xr-x  5 root root 4096 Jul  5 18:19 awstats-6.95  
  8. drwxr-xr-x  2 root root 4096 Oct  1  2009 bin  
  9. drwxr-xr-x  2 root root 4096 Oct  1  2009 etc  
  10. drwxr-xr-x  2 root root 4096 Oct  1  2009 games  
  11. drwxr-xr-x  2 root root 4096 Oct  1  2009 include  
  12. drwxr-xr-x  2 root root 4096 Oct  1  2009 lib  
  13. drwxr-xr-x  2 root root 4096 Oct  1  2009 libexec  
  14. lrwxrwxrwx  1 root root   26 Jun  1 11:16 mysql -> mysql-5.5.24-linux2.6-i686  
  15. drwxr-xr-x 13 root root 4096 Jun  1 11:29 mysql-5.5.24-linux2.6-i686  
  16. drwxr-xr-x  7 root root 4096 Jun  1 13:52 php  
  17. drwxr-xr-x  2 root root 4096 Oct  1  2009 sbin  
  18. drwxr-xr-x  4 root root 4096 May 21 20:40 share  
  19. drwxr-xr-x  2 root root 4096 Oct  1  2009 src 

(3)进入/usr/local/awstats/tools/目录中,运行perl awstats_configure.pl 脚本。

  1. [root@localhost local]# cd awstats  
  2. [root@localhost awstats]# ls  
  3. docs  README.TXT  tools  wwwroot  
  4. [root@localhost awstats]# cd tools/  
  5. [root@localhost tools]# ls  
  6. awstats_buildstaticpages.pl  awstats_configure.pl  awstats_exportlib.pl  awstats_updateall.pl  httpd_conf   
  7. [root@localhost tools]# perl awstats_configure.pl  /执行此命令 
  8.  
  9. ----- AWStats awstats_configure 1.0 (build 1.8) (c) Laurent Destailleur -----  
  10. This tool will help you to configure AWStats to analyze statistics for  
  11. one web server. You can try to use it to let it do all that is possible  
  12. in AWStats setup, however following the step by step manual setup  
  13. documentation (docs/index.html) is often a better idea. Above all if:  
  14. - You are not an administrator user,  
  15. - You want to analyze downloaded log files without web server,  
  16. - You want to analyze mail or ftp log files instead of web log files,  
  17. - You need to analyze load balanced servers log files,  
  18. - You want to 'understand' all possible ways to use AWStats...  
  19. Read the AWStats documentation (docs/index.html).  
  20.  
  21. -----> Running OS detected: Linux, BSD or Unix  
  22. Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.  
  23. If you want to use standard directory, you should first move all content  
  24. of AWStats distribution from current directory:  
  25. /usr/local/awstats-6.95  
  26. to standard directory:  
  27. /usr/local/awstats  
  28. And then, run configure.pl from this location.  
  29. Do you want to continue setup from this NON standard directory [yN] ? y  /我们已建立awstats-6.95到awstats的链接文件所以选择y。
  30.  
  31. -----> Check for web server install  
  32.   Found Web server Apache config file '/etc/httpd/httpd.conf'  
  33.  
  34. -----> Check and complete web server config file '/etc/httpd/httpd.conf'  
  35. Warning: You Apache config file contains directives to write 'common' log files  
  36. This means that some features can't work (os, browsers and keywords detection).  
  37. Do you want me to setup Apache to write 'combined' log files [y/N] ? N  
  38.   Add 'Alias /awstatsclasses "/usr/local/awstats-6.95/wwwroot/classes/"'  
  39.   Add 'Alias /awstatscss "/usr/local/awstats-6.95/wwwroot/css/"'  
  40.   Add 'Alias /awstatsicons "/usr/local/awstats-6.95/wwwroot/icon/"'  
  41.   Add 'ScriptAlias /awstats/ "/usr/local/awstats-6.95/wwwroot/cgi-bin/"'  
  42.   Add '<Directory>' directive  
  43.   AWStats directives added to Apache config file.  
  44.  
  45. -----> Update model config file '/usr/local/awstats-6.95/wwwroot/cgi-bin/awstats.model.conf'  
  46.   File awstats.model.conf updated.  
  47.  
  48. -----> Need to create a new config file ?  
  49. Do you want me to build a new AWStats config/profile  
  50. file (required if first install) [y/N] ? y /这是我们第一次安装所以选择y  
  51.  
  52. -----> Define config file name to create  
  53. What is the name of your web site or profile analysis ?  
  54. Example: www.mysite.com  
  55. Example: demo  
  56. Your web site, virtual server or profile name:  
  57. > www.qingmu.com  /输入你要分析的网站的地址
  58.  
  59. -----> Define config file path  
  60. In which directory do you plan to store your config file(s) ?  
  61. Default: /etc/awstats  
  62. Directory path to store config file(s) (Enter for default):  
  63. > /按回车键,awstats的配置文件放在/etc/awstats中
  64.  
  65. -----> Create config file '/etc/awstats/awstats.www.qingmu.com.conf'  
  66.  Config file /etc/awstats/awstats.www.qingmu.com.conf created.  
  67.  
  68. -----> Restart Web server with '/sbin/service httpd restart'  
  69. Stopping httpd:                                            [  OK  ]  
  70. Starting httpd:                                            [  OK  ]  
  71.  
  72. -----> Add update process inside a scheduler  
  73. Sorry, configure.pl does not support automatic add to cron yet.  
  74. You can do it manually by adding the following command to your cron:  
  75. /usr/local/awstats-6.95/wwwroot/cgi-bin/awstats.pl -update -config=www.qingmu.com  
  76. Or if you have several config files and prefer having only one command:  
  77. /usr/local/awstats-6.95/tools/awstats_updateall.pl now  
  78. Press ENTER to continue...   
  79.  
  80.  
  81. A SIMPLE config file has been created: /etc/awstats/awstats.www.qingmu.com.conf  
  82. You should have a look inside to check and change manually main parameters.  
  83. You can then manually update your statistics for 'www.qingmu.com' with command:  
  84. > perl awstats.pl -update -config=www.qingmu.com  
  85. You can also read your statistics for 'www.qingmu.com' with URL:  
  86. > http://localhost/awstats/awstats.pl?config=www.qingmu.com  
  87.  
  88. Press ENTER to finish...  

(4)修改awstats的配置文件/etc/awstats/awstats.www.qingmu.com.conf 。主要修改如下几项:

  1. LogFile="/usr/local/awstats/my.log" /日志存放位置,要确保my.log文件存在
  2. LogType=W   
  3. LogFormat=1 
  4. SiteDomain="www.qingmu.com" 
  5. DirData="/var/lib/awstats" /确保此目录存在

(5)对awstats的数据库进行更新。

  1. [root@localhost httpd]# cd /usr/local/awstats  
  2. [root@localhost awstats]# ls  
  3. docs  my.log  README.TXT  tools  wwwroot  
  4. [root@localhost awstats]# cd wwwroot/cgi-bin/  /进入到/usr/local/awstats/wwwroot/cgi-bin目录中
  5. [root@localhost cgi-bin]# ls  
  6. awredir.pl  awstats.model.conf  awstats.pl  lang  lib  plugins  
  7. [root@localhost cgi-bin]# perl awstats.pl -config=www.qingmu.com -update /执行此命令 
  8. Create/Update database for config "/etc/awstats/awstats.www.qingmu.com.conf" by AWStats version 6.95 (build 1.943)  
  9. From data in log file "/usr/local/awstats/my.log"...  
  10. Phase 1 : First bypass old records, searching new record...  
  11. Searching new records from beginning of log file...  
  12. Jumped lines in file: 0  
  13. Parsed lines in file: 0  
  14.  Found 0 dropped records,  
  15.  Found 0 corrupted records,  
  16.  Found 0 old records,  
  17.  Found 0 new qualified records. 

(6)如果你用的是2.4.2版本的apache,那还要修改apache的主配置文件。

    <Directory "/usr/local/awstats-6.95/wwwroot"> /将这个目录中的文件修改以下三项
  1.      Options None  
  2.      AllowOverride None  
  3.      Require all granted  
  4. </Directory> 

(7)在你的浏览器中输入。

http://www.qingmu.com/awstats/awstats.pl?config=www.qingmu.com如果出现以下效果:

awstats的安装与配置_linux

则在apache的主配置文件中开启如下模块:

LoadModule cgi_module modules/mod_cgi.so 

然后再打开如下页面:

awstats的安装与配置_日志分析_02

(8)如果出现“从未更新”的字样,则先用如下命令进行更新:

    [root@localhost cgi-bin]# perl awstats.pl -config=www.qingmu.com -update 

如果还不行,那就是awstats和apache两者识别的日志格式不同。可以修改apache主配置文件中的日志格式。