分类: 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"
access_log /var/log/nginx/zn.log main; error_log /var/log/nginx/zn.log error;
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 }
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 访问