awstats部署

1.下载awstats并解压
wget http://prdownloads.sourceforge.net/awstats/awstats-6.95.tar.gz
tar -C /usr/local/awstats zxvf awstats-6.95.tar.gz
mkdir -m 755 /usr/local/awstats/data/

2.初始化配置awstats
perl /usr/local/awstats/tools/awstats_configure.pl
输入需分析的域名即可

3.修改配置文件,使用日志自动合并分析
vi /etc/awstats/awstats.www.test.com.conf
LogFile="/usr/local/awstats/tools/logresolvemerge.pl /data/*_access_log_%YYYY-24%MM-24%DD-24|"

4.修改apache配置文件
每天自动切割日志文件
vi httpd.conf
CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/53_access_log_%Y%m%d 86400 480" combined
service httpd restart

5.添加IP及地区的分析插件
cpan install Geo::IP
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar zxvf GeoIP.tar.gz
cd GeoIP-1.4.6/
./configure && make && make install
wget http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz
tar zxvf Geo-IP-1.38.tar.gz
cd Geo-IP-1.38
perl Makefile.PL && make && make install
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
cp GeoLiteCity.dat /usr/local/share/GeoIP/
vi /etc/awstats/awstats.www.test.com.conf
修改以下参数
LoadPlugin="tooltips"
LoadPlugin="decodeutfkeys"
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"

6.设置awstats服务器与apache主机互信
ssh-keygen -t rsa
chmod 700 ~/.ssh
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
rcp ~/.ssh/authorized_keys ip地址:~/.ssh/authorized_keys

7.添加自动分析脚本
01 03 * * * /sbin/awstats.sh > /var/log/awstat.log
脚本内容
POSTFIX=`date -dyesterday '+%Y%m%d'`
scp ip地址:/var/log/httpd/53_access_log_$POSTFIX /data/
scp ip地址:/var/log/httpd/54_access_log_$POSTFIX /data/
sleep 10
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.test.com
sleep 10
rm -f /data/53_access_log_$POSTFIX /data/54_access_log_$POSTFIX

大功告成
http://ip地址/awstats/awstats.pl?config=www.test.com

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8078021/viewspace-1063383/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8078021/viewspace-1063383/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值