Chinaunix首页 | 论坛 | 博客
  • 博客访问: 558714
  • 博文数量: 114
  • 博客积分: 5611
  • 博客等级: 大校
  • 技术积分: 1027
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-19 08:55
文章分类

全部博文(114)

文章存档

2011年(29)

2010年(20)

2009年(1)

2008年(11)

2007年(53)

分类: LINUX

2008-01-09 14:09:31

一、首先修改httpd.conf   httpd-vhost.conf

log模式由common改成combined

vi /usr/local/apache2/conf/httpd.conf

vi /usr/local/apache2/conf/extra/httpd-vhost.conf

/usr/local/apache2/bin/apachectl restart

 

 

二、安装Geo-IP

wget 

wget

wget 

 

cd /usr/local/src

 

tar zxvf GeoIP-1.4.3.tar.gz
cd GeoIP-1.4.3
./configure
make
make install
 
tar zxvf Geo-IP-1.30.tar.gz
cd Geo-IP-1.30
perl Makefile.PL
make
make install


tar zxvf Geo-IPfree-0.2.tar.gz
cd Geo-IPfree-0.2
perl Makefile.PL
make
make install

 

三、安装awstats

1、下载并安装

wget 

tar zxvf awstats-6.7.tar.gz

mv awstats-6.7 /usr/local/awstats

cd /usr/local/awstats

cd /usr/local/awstats/tools

perl awstats_configure.pl

 

 

 

2、配置

vi /etc/awstats/awstats.

DirData="/usr/local/apache2/htdocs/awstats/data"

DirIcons="/awstats/icon"

DirCgi="/usr/local/apache2/cgi-bin/awstats"

LogFile="/usr/local/apache2/logs/"

SiteDomain=

HostAliases=

AllowToUpdateStatsFromBrowser=1

Lang="cn"

LoadPlugin=”decodutfkeys”

LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"

#LoadPlugin="geoipfree"

#LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"

 

注释:GeoIP.dat geoipfree2者只能选一个,不能同时使用的!我选的是GeoIP.dat

加了GeoLiteCity.dat 貌似有反向的解析,整体的awstats会变慢。所以实验了一下,实际的应用不建议使用!

同时经过实际的测试geoipfree2的准确性太差,把国内的地址认为是美国的,所以还是使用GeoIP吧。

 

3、拷贝cgi、data、icon

cp -r /usr/local/awstats/wwwroot/cgi-bin/ /usr/local/apache2/cgi-bin/awstats

mkdir -p /usr/local/apache2/htdocs/awstats/data

chmod 777 /usr/local/apache2/htdocs/awstats/data

cp -r /usr/local/awstats/wwwroot/icon/ /usr/local/apache2/htdocs/web/awstats/icon

 

/usr/local/apache2/bin/apachectl restart

 

/usr/local/apache2/cgi-bin/awstats/awstats.pl -update -config=

在浏览器中打开以下网站

 

注释:

LogFile (APCHE CustomLog日志的绝对路径)
DirData  (指定AWSTATS生成数据的存放目录,可以任意指定,但注意目录要具有读写权限,可以设置为777或755)
DirCgi   (cgi的路径,是相对于网站根目录的绝对路径,我这里没有指定网站根目录是因为apache的配置默认有cgi-bin的缺省目录,我是拷贝到这个缺省目录中的)
DirIcons  (icon的路径,是相对于网站根目录的绝对路径,这个就没办法了,只能放到每个要设定的虚拟域名网站的目录中了)
SiteDomain (输入你的域名)
HostAliases (主机别名,如果还有其他的二级域名或三级域名,请在此添加。)
AllowToUpdateStatsFromBrowser (是否允许用户从浏览器中实时更新统计,这个功能在测试的时候很有用!)
Lang="cn" (设置网页显示语言为简体中文。)

 

 

 

更新Geo-IP的2个免费数据库

mkdir -p /home/soft/awstats

cd /home/soft/awstats

wget

wget

gunzip GeoLiteCity.dat.gz

gunzip GeoIP.dat.gz

cp GeoLiteCity.dat /usr/local/share/GeoIP/

cp GeoIP.dat /usr/local/share/GeoIP/

 

cd /usr/local/share/GeoIP

 

测试AWSTATS

/usr/local/apache2/cgi-bin/awstats/awstats.pl -update -config=

 

如果不出现错误信息并且得到统计数据回显则成功!

访问地址:

 

设置crond

crontab -e
增加:(可设置为每天零时进行更新)
0 0 * * * /usr/local/apache2/cgi-bin/awstats/awstats.pl -update -config=

 

修改httpd.conf设置/usr/local/apache2/cgi-bin/awstats目录访问权限

这样就可以通过用户名和密码来限制可以访问的计算机了

 

vi /usr/local/apache2/conf/httpd.conf

 

/usr/local/apache2/">
AllowOverride authconfig
Order allow,deny
Allow from all

 

  vi  /usr/local/apache2/htdocs/cgi-bin/awstats/.htaccess

AuthType Basic

AuthName "请输入用户名和密码"

AuthUserFile /usr/local/apache2/cgi-bin/awstats/passwords
Require valid-user

htpasswd -c /usr/local/apache2/cgi-bin/awstats/passwords adminsarg

重复输入2次密码

 

/usr/local/apache2/bin/apachectl restart

 

完工!

 

注释:perl awstats_configure.pl的过程

----- AWStats awstats_configure 1.0 (build 1.7) (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'

 

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

Example: demo

Your web site, virtual server or profile name:

>

 

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

 Config file /etc/awstats/awstats. 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=

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.

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

You can then manually update your statistics for '' with command:

> perl awstats.pl -update -config=

You can also read your statistics for '' with URL:

>

 

Press ENTER to finish...

 

 

注释:是借用的,不是真的,是举个例子的!

阅读(2139) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~