参考如下文章
http://centoshelp.org/servers/configuring-awstats-multiple-domains-hosted-on-the-same-server/
首先安装epel 和rpmforge 源
yum install install awstats GeoIP-data perl-Geo-IP cronolog
geoip的国家和城市的数据装不了要手动下载
mkdir /var/www/GeoIP; cd /var/www/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoIP.dat.gz GeoLiteCity.dat.gz
vi /etc/httpd/conf/httpd.conf
修改日志格式
CustomLog “|/usr/sbin/cronolog /var/log/httpd/www.xx.com.%Y%m%d.log” combined
cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.www.xx.com.conf
vi /etc/awstats/awstats.stats.example.com.conf We will be editing the following lines: 1. LogFile=”/var/log/httpd/www.jxx.com.%YYYY-0%MM-0%DD-0.log”
可以查看awastats的配置文件上方有详细说明 -24是前一天的日志
2. SiteDomain=”stats.example.com” 3. HostAliases=”stats.example.com” 4. DirData=”/var/www/stats.example.com/” 5. LoadPlugin=”geoip GEOIP_STANDARD /var/lib/GeoIP/GeoIP.dat” (using the yum install method) 6. LoadPlugin=”geoip GEOIP_STANDARD /var/www/GeoIP/GeoIP.dat” (using the MaxMind direct download method) 7. LoadPlugin=”geoip_city_maxmind GEOIP_STANDARD /var/www/GeoIP/GeoLiteCity.dat” (using the MaxMind direct download method)
awstats与apache的日志格式不一样 要修改成上述格式
vi /etc/httpd/conf.d/awstats.conf
allow forn all
perl /var/www/awstats/awstats.pl -config=www.xx.com -update > /dev/null 2>&1
<Directory "/var/www/stats.example.com"> AuthName "Restricted Area" AuthType Basic AuthBasicProvider file AuthUserFile /var/www/stats.example.com/.htpasswds AuthGroupFile /dev/null require valid-user </Directory>
htpasswd -bc admin metc7626160 .htpasswd
遇到点故障,发现脚本每天都没有执行crond 系统是centos6 结果发现minimal最小化安装没有安装crontabs yum install 一下就ok了