Chinaunix首页 | 论坛 | 博客
  • 博客访问: 115749
  • 博文数量: 34
  • 博客积分: 1485
  • 博客等级: 上尉
  • 技术积分: 351
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-10 11:06
文章分类

全部博文(34)

文章存档

2011年(2)

2010年(17)

2009年(4)

2008年(7)

2007年(4)

我的朋友

分类: LINUX

2010-03-29 15:23:43

相关下载




安装环境 ubuntu 9.04
1.安装awstats
tar -zxvf awstats-6.95.tar.gz
mv awstats-6.95 /usr/local/awstats
cd /usr/local/awstats/tools/
./awstats_configure.pl

Config file path ('none' to skip web server setup): #如果在apache 下,运行,写入apache 设置主文件.用nginx 请写入none

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

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

文件以经创建, 在 /etc/awstats/awstats.zn.conf
修改配置文件以下几行.
日志文件设置
这是我的设置,后面的是logrotate 自动滚动后的日期,在日志滚动后执行,这样不会丢记录.
LogFile="/var/log/nginx/zn.log-%YYYY%MM%DD"
Format设置
LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %otherquot"
设置域名
SiteDomain=""
设置别名
HostAliases=" 127.0.0.1 localhost"

2 安装 geo ip 模块

Geo-IP C-API
tar -zxvf GeoIP-1.4.6.tar.gz
cd GeoIP-1.4.6
./configure
make
make install

Geo-IP Perl-API
ar -zxvf Geo-IP-1.38.tar.gz
cd Geo-IP-1.38
perl Makefile.PL
make
make install

注意以上两个的顺序.
安装完成后会创建目录/usr/local/share/GeoIP/

安装国家free数据库
gzip -d GeoLiteCity.dat.gz
mv GeoLiteCity.dat /usr/local/share/GeoIP/

GeoLite ASN数据库
gzip -d GeoIPASNum.dat.gz
mv GeoIPASNum.dat /usr/local/share/GeoIP/

修改/etc/awstats/awstats.zn.conf
加入以下几行.

LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"
LoadPlugin="geoip_org_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoIPASNum.dat"

3.修改nginx 配置文件.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
设置 的log
access_log  /var/log/nginx/zn.log  main;
error_log   /var/log/nginx/zn.log  error;

如果要用nginx 来运行awstats 请看前文, nginx下运行perl(nagios)参照修改.

4.设置logrotate
touch /etc/logrotate.d/nginx
vi /etc/logrotate.d/nginx

/var/log/nginx/*.log {
    daily
    compress
    delaycompress
    dateext
    maxage 365
    rotate 99
#    size=+4096k
    notifempty
    missingok
    create 644 project root
    sharedscripts
    postrotate
	kill -USR1 `pgrep -U root nginx`
    endscript
}

测试
logrotate -d /etc/logrotate.d/nginx
运行
logrotate -f /etc/logrotate.d/nginx

4设置awstats 自动更新
crontab -e
0 8 * * * /usr/bin/perl /usr/local/awstats/tools/awstats_updateall.pl now >>/var/log/awstats-update.log 2>&1

awstats 访问


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