奇码科技的美国空间是带有详细的统计流量工具awstats,AWStats是一套免费基于Perl的网站日志分析工具。这个工具界面较为友好,执行速度快,扩展功能众多,在国外空间使用apache服务 器的,AWStats是当之无愧的首选。

[root@webserver ~]# rpm -ivh awstats-6.9-1.noarch.rpm

error: Failed dependencies:

perl(LWP::UserAgent) is needed by awstats-6.9-1.noarch

包依赖关系,需要先安装下面的包

[root@webserver src]# yum -y install perl-libwww-perl

Loading "security" plugin

Loading "rhnplugin" plugin

This system is not registered with RHN.

RHN support will be disabled.

rhel5-local 100% |=========================| 1.3 kB 00:00

Setting up Install Process

Parsing package install arguments

Resolving Dependencies

--> Running transaction check

---> Package perl-libwww-perl.noarch 0:5.805-1.1.1 set to be updated

--> Processing Dependency: perl(URI::URL) for package: perl-libwww-perl

--> Processing Dependency: perl(URI) for package: perl-libwww-perl

--> Processing Dependency: perl(HTML::Entities) for package: perl-libwww-perl

--> Processing Dependency: perl(Compress::Zlib) for package: perl-libwww-perl

--> Processing Dependency: perl(URI::Heuristic) for package: perl-libwww-perl

--> Processing Dependency: perl(URI::Escape) for package: perl-libwww-perl

--> Processing Dependency: perl-HTML-Parser >= 3.33 for package: perl-libwww-perl

--> Running transaction check

---> Package perl-Compress-Zlib.i386 0:1.42-1.fc6 set to be updated

---> Package perl-URI.noarch 0:1.35-3 set to be updated

---> Package perl-HTML-Parser.i386 0:3.55-1.fc6 set to be updated

--> Processing Dependency: perl-HTML-Tagset >= 3.03 for package: perl-HTML-Parser

--> Processing Dependency: perl(HTML::Tagset) for package: perl-HTML-Parser

--> Running transaction check

---> Package perl-HTML-Tagset.noarch 0:3.10-2.1.1 set to be updated

--> Finished Dependency Resolution

 

Dependencies Resolved

 

=============================================================================

Package Arch Version Repository Size

=============================================================================

Installing:

perl-libwww-perl noarch 5.805-1.1.1 rhel5-local 376 k

Installing for dependencies:

perl-Compress-Zlib i386 1.42-1.fc6 rhel5-local 52 k

perl-HTML-Parser i386 3.55-1.fc6 rhel5-local 92 k

perl-HTML-Tagset noarch 3.10-2.1.1 rhel5-local 14 k

perl-URI noarch 1.35-3 rhel5-local 116 k

 

Transaction Summary

=============================================================================

Install 5 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

 

Total download size: 651 k

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing: perl-HTML-Tagset ######################### [1/5]

Installing: perl-HTML-Parser ######################### [2/5]

Installing: perl-URI ######################### [3/5]

Installing: perl-Compress-Zlib ######################### [4/5]

Installing: perl-libwww-perl ######################### [5/5]

 

Installed: perl-libwww-perl.noarch 0:5.805-1.1.1

Dependency Installed: perl-Compress-Zlib.i386 0:1.42-1.fc6 perl-HTML-Parser.i386 0:3.55-1.fc6 perl-HTML-Tagset.noarch 0:3.10-2.1.1 perl-URI.noarch 0:1.35-3

Complete!

[root@webserver src]# rpm -ivh awstats-6.9-1.noarch.rpm

Preparing... ########################################### [100%]

1:awstats ########################################### [100%]

 

----- AWStats 6.9 - Laurent Destailleur -----

AWStats files have been installed in /usr/local/awstats

 

If first install, follow instructions in documentation

(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:

Step 1 : Install and Setup with awstats_configure.pl (or manually)

Step 2 : Build/Update Statistics with awstats.pl

Step 3 : Read Statistics

[root@webserver src]# cd /usr/local/awstats/tools/

[root@webserver tools]# ./awstats_configure.pl

 

----- AWStats awstats_configure 1.0 (build 1.8) (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):

> /usr/local/httpd/conf/httpd.conf

 

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

 

-----> 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

 

-----> 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.www.test.com.conf'

Error: Failed to open '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf' for read.

/etc/awstats下没有awstats.model.conf文件造成的错误

[root@webserver tools]# cp /usr/etc/awstats/awstats.model.conf /etc/awstats/

[root@webserver tools]# ./awstats_configure.pl

 

----- AWStats awstats_configure 1.0 (build 1.8) (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):

> /usr/local/httpd/conf/httpd.conf

 

-----> Check and complete web server config file '/usr/local/httpd/conf/httpd.conf'

All AWStats directives are already present.

 

-----> Update model config file '/etc/awstats/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

 

-----> 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.www.test.com.conf'

Config file /etc/awstats/awstats.www.test.com.conf created.

 

-----> 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.test.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.test.com.conf

You should have a look inside to check and change manually main parameters.

You can then manually update your statistics for 'www.test.com' with command:

> perl awstats.pl -update -config=www.test.com

You can also read your statistics for 'www.test.com' with URL:

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

 

Press ENTER to finish...

[root@webserver tools]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl --update -config=www.test.com

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.www.test.com.conf' file, web server or permissions) may be wrong.

Check config file, permissions and AWStats documentation (in 'docs' directory).

对于/var/lib/awstats目录没有写入权限造成的

[root@webserver tools]# chmod 777 /var/lib/awstats

chmod: cannot access `/var/lib/awstats': No such file or directory

[root@webserver tools]# mkdir /var/lib/awstats

[root@webserver tools]# chmod 777 /var/lib/awstats

[root@webserver tools]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl --update -config=www.test.com

Create/Update database for config "/etc/awstats/awstats.www.test.com.conf" by AWStats version 6.9 (build 1.925)

From data in log file "/var/log/httpd/mylog.log"...

Error: Couldn't open server log file "/var/log/httpd/mylog.log" : No such file or directory

Setup ('/etc/awstats/awstats.www.test.com.conf' file, web server or permissions) may be wrong.

Check config file, permissions and AWStats documentation (in 'docs' directory).

日志路径错位造成的

[root@webserver tools]# vi /etc/awstats/awstats.www.test.com.conf

LogFile="/usr/local/httpd/logs/access_log"

 

 

[root@webserver tools]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl --update -config=www.test.com

Create/Update database for config "/etc/awstats/awstats.www.test.com.conf" by AWStats version 6.9 (build 1.925)

From data in log file "/usr/local/httpd/logs/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: 30

Found 0 dropped records,

Found 30 corrupted records,

Found 0 old records,

Found 0 new qualified records.

从新启动apache

[root@webserver tools]# /usr/local/httpd/bin/apachectl stop

[root@webserver tools]# /usr/local/httpd/bin/apachectl start

添加定时分析指令

[root@webserver logs]# crontab -e

20 1 * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl --update -config=www.test.com