前言,公司要用awstats做web服务器的流量统计,到51cto找了下,发现文章很少,所以写了这篇文章,记录下自己配置的过程,也希望能帮到有需要的朋友.
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/s1
ServerName s1.domain1.com
ErrorLog logs/s1_web-error_log
TransferLog logs/s1_web-access_log
</VirtualHost>
|
----- AWStats awstats_configure 1.0 (build 1.6) (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 '/usr/local/apache2/conf/httpd.conf'
|
-----> 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
|
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: [url]www.mysite.com[/url]
Example: demo
Your web site, virtual server or profile name:
Ø
s1.domain1.com
|
-----> 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):
>
回车
|
-----> Create config file '/etc/awstats/awstats.s1.domain1.com.conf'
Config file /etc/awstats/awstats.s1.domain1.com.conf created.
|
-----> Restart Web server with '/sbin/service httpd restart'
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
|
-----> 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=s1.domain1.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.s1.domain1.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 's1.domain1.com' with command:
> perl awstats.pl -update -config=s1.domain1.com
You can also read your statistics for 's1.domain1.com' with URL:
Ø
[url]http://localhost/awstats/awstats.pl?config=s1.domain1.com[/url]
Press ENTER to finish...
|
将
CustomLog logs/access_log common
改为
CustomLog logs/access_log combined
在文件的最后面增加了
# Directives to allow use of AWStats as a CGI
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/"
# This is to permit URL access to scripts/files in AWStats directory.
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
|
Forbidden
You don't have permission to access /awstats/awstats.pl on this server
|
# LogFile="/var/log/httpd/mylog.log"
LogFile="/usr/local/apache2/logs/s1_web-access_log"
指到
apche
的日志
|
LogType=W
表示分析的是
web
日志
|
LogFormat=1
表示日志格式为
combined
|
SiteDomain="s1.domain1.com"
域名
|
HostAliases="s1.domain1.com [url]www.s1.domain1.com[/url] 127.0.0.1 localhost"
这个变量的意思是这个域的别名
.
即多个域名对应同一网站的情况
,
这句是自动生成的
.
我这里没有用到所以就没有改
.
|
Error: AWStats database directory defined in config file by 'DirData' parameter (/var/lib/awstats) does not exist or is not writable.
Setup ('/etc/awstats/awstats.s1.domain1.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
|
Error: AWStats database directory defined in config file by 'DirData' parameter (/var/lib/awstats) does not exist or is not writable.
Setup ('/etc/awstats/awstats.s1.domain1.com.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
|
Update for config "/etc/awstats/awstats.s1.domain1.com.conf"
With data in log file "/usr/local/apache2/logs/s1_web-access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Jumped lines in file: 0
Parsed lines in file: 1
处理的总行数
(apache
的日志是一行代表一个记录
)
Found 0 dropped records,
Found 1 corrupted records,
发现了一个损坏的记录
Found 0 old records,
Found 0 new qualified records.
|
192.168.0.28 - - [30/Aug/2007:13:04:05 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; TencentTraveler )"
192.168.0.28 - - [30/Aug/2007:13:05:30 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; TencentTraveler )"
192.168.0.28 - - [30/Aug/2007:13:05:30 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; TencentTraveler )"
192.168.0.28 - - [30/Aug/2007:13:05:30 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; TencentTraveler )"
192.168.0.28 - - [30/Aug/2007:13:05:31 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; TencentTraveler )"
192.168.0.28 - - [30/Aug/2007:13:05:31 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; TencentTraveler )"
……
|
Update for config "/etc/awstats/awstats.s1.domain1.com.conf"
With data in log file "/usr/local/apache2/logs/s1_web-access_log"...
Phase 1 : First bypass old records, searching new record...
Direct access to last remembered record has fallen on another record.
So searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 6
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 6 new qualified records.
|