…生活與工作…個人的生活雜記….

在QNAP 安裝 AWSTATS + GeoIP

步驟:

增加apache access_Log

vim /etc/config/apache/extra/apache-myconfig.conf

CustomLog logs/access_log combined
ErrorLog logs/error_log
LogLevel info

vim /etc/config/apache/apache.conf

Include /etc/config/apache/extra/apache-myconfig.conf

/etc/init.d/Qthttpd.sh restart

安裝perl

image1475588951

 

ln -sf /share/MD0_DATA/.qpkg/Optware/bin/perl /usr/bin

 

安裝AWSTATS

下載AWSTATS

cp 到 /share/MD0_DATA/.qpkg 下

cd /share/MD0_DATA/.qpkg
tar xvzf awstats-x.x.x.tar.gz
mv awstats-x.x.x awstats
chown -R admin.administrators awstats
chmod -R a+x awstats
mkdir -p /share/MD0_DATA/.qpkg/awstats/db
mkdir -p /etc/config/awstats

ln -sf /share/MD0_DATA/.qpkg/awstats /usr/local
rm -f /var/lib/awstats
ln -sf /share/MD0_DATA/.qpkg/awstats/db /var/lib/awstats
ln -sf /etc/config/awstats /etc
cd /usr/local/awstats/tools
perl awstats_configure.pl

輸入 “y”

輸入 “/usr/local/apache/conf/apache.conf”

輸入 “y”

輸入 “顯示名稱”

按下”enter”2次

vim /etc/awstats/awstats.xxxxxxxx.conf

LogFile="/usr/local/apache/logs/access_log"
LogFormat="%host %other %logname %time1 %methodurl %code %bytesd"

vim /etc/config/apache/apache.conf

<Directory "/share/MD0_DATA/.qpkg/awstats/wwwroot">

Options None
AllowOverride None
Order deny,allow
Deny from all
Allow from 192.168.0.0/255.255.255.0

</Directory>

測試

/share/MD0_DATA/.qpkg/awstats/tools/awstats_updateall.pl now

Running '"/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -update -config=www.est.idv.tw -configdir="/etc/awstats"' to update config www.est.idv.tw
 Create/Update database for config "/etc/awstats/awstats.www.est.idv.tw.conf" by AWStats version 7.5 (build 20160301)
 From data in log file "/usr/local/apache/logs/access_log"...
 Phase 1 : First bypass old records, searching new record...
 Direct access after last parsed record (after line 1060)
 Jumped lines in file: 1060
  Found 1060 already parsed records.
 Parsed lines in file: 155
  Found 0 dropped records,
  Found 0 comments,
  Found 0 blank records,
  Found 0 corrupted records,
  Found 0 old records,
  Found 155 new qualified records.

 

增加crontab

vim /etc/config/crontab

0 */2 * * * /share/MD0_DATA/.qpkg/awstats/tools/awstats_updateall.pl now

crontab /etc/config/crontab

修改繁中

vim /etc/awstats/awstats.xxxxxxxx.conf

Lang="tw"

 

安裝 GeoIP Perl Moudle
wget http://www.maxmind.com/download/geoip/api/pureperl/Geo-IP-PurePerl-1.25.tar.gz
ipkg install perl-ExtUtils-MakeMaker
tar zxvf Geo-IP-PurePerl-1.25.tar.gz
cd Geo-IP-PurePerl-1.25 ; perl Makefile.PL ; make ; make test ; make install

Modify awstats.site.conf
vi /etc/awstats/awstats.xxxxxxxx.conf
DNSLookup=0
LoadPlugin="geoip GEOIP_STANDARD /share/MD0_DATA/.qpkg/Optware/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /share/MD0_DATA/.qpkg/Optware/share/GeoIP/GeoLiteCity.dat"

測試

/share/MD0_DATA/.qpkg/awstats/tools/awstats_updateall.pl now

 

每次更新FW後,需重新執行一次

ln -sf /share/MD0_DATA/.qpkg/awstats /usr/local
rm -f /var/lib/awstats
ln -sf /share/MD0_DATA/.qpkg/awstats/db /var/lib/awstats
ln -sf /etc/config/awstats /etc