Differences between current version and predecessor to the previous major change of AwStatsNotes.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 4 | Last edited on Monday, August 21, 2006 8:56:53 am | by CraigBox | |
Older page: | version 1 | Last edited on Friday, July 21, 2006 10:09:36 am | by CraigBox | Revert |
@@ -1,11 +1,11 @@
-!!Debian/Ubuntu AWStats virtual host setup
+!
!!Debian/Ubuntu AWStats virtual host setup
Install awstats with <tt>apt-get install awstats</tt>. To get geostats working, so you can tell the countries of origin of your visitors, <tt>apt-get install libnet-ip-perl libgeo-ipfree-perl</tt>.
-! Configuring Apache
+!
! Configuring Apache
-Drop this in /etc/apache2/awstats.
conf:
+Drop this in /etc/apache2/conf.d/awstats
:
<verbatim>
Alias /awstats-icon/ /usr/share/awstats/icon/
<Directory /usr/share/awstats/icon>
@@ -15,18 +15,16 @@
Allow from all
</Directory>
</verbatim>
-Then, add <tt>Include /etc/apache2/awstats.conf</tt> to /etc/apache2/apache2.conf.
-
-
! Configuring AWStats
+!
! Configuring AWStats
For each vhost you want to analyse, create a /etc/awstats/awstats.vhost.domain.co.nz.conf file, looking like such:
<verbatim>
LogFile="/var/www/vhost.domain.co.nz/log/access.log"
LogType=W
-LogFormat=4
+LogFormat=1
LogSeparator=" "
SiteDomain="vhost.domain.co.nz"
HostAliases="localhost 127.0.0.1"
DNSLookup=1
@@ -34,10 +32,70 @@
DirCgi="/cgi-bin"
DirIcons="/awstats-icon"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=2
+LoadPlugin="geoipfree"
</verbatim>
-To
be continued after scones
!
+Use <tt>~LogFormat 1</tt> if you are using 'combined' Apache logs, which are used by default. Use <tt>~LogFormat 4</tt> otherwise
+
+!!Updating the page
+
+Some people like to cron a stats update to happen more often. I will
be happy with once a day, so I'll use my daily logrotate time. I have a seperate logrotate file for each vhost:
+
+<verbatim>
+/var/www/vhost.domain.co.nz/log/*.log {
+ daily
+ missingok
+ rotate 7
+ compress
+ delaycompress
+ notifempty
+ create 640 www-data www-data
+ prerotate
+ /usr/lib/cgi-bin/awstats.pl -config=vhost.domain.co.nz -update
+ endscript
+}
+</verbatim>
+
+You could put a cron fragment like this somewhere:
+
+<verbatim>
+3,33 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.vhost.domain.co.nz.conf -a -r /var/log/apache/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=vhost.domain.co.nz -update >/dev/null
+</verbatim>
+
+!!Password protect your stats
+
+We will use Apache's .htaccess mechanism to ensure you can only see the stats if you know a password.
+
+<tt>htpasswd -c /etc/awstats/awstats.htpasswd ''username''</tt>
+
+Now, edit /etc/apache2/sites-enabled/000-default, under ''<Directory "/usr/lib/cgi-bin">'', add
+
+<verbatim>
+ AuthType basic
+ AuthName "cgi-bin restricted"
+ AuthUserFile /etc/awstats/awstats.htpasswd
+
+ <Files awstats.pl>
+ Require valid-user
+ </Files>
+</verbatim>
+
+Reload Apache, and try navigating to http''''://primary.sitename.co.nz/cgi-bin/awstats.pl?config=vhost.domain.co.nz.
+
+I am only allowing cgi-bin on my primary host; a good compromise is to set up a redirect from http:''''//vhost.domain.co.nz/stats/ to the primary hostname; in /etc/apache2/sites-enabled/vhost.domain.co.nz:
+
+<verbatim>
+ RedirectMatch permanent /stats http://primary.sitename.co.nz/cgi-bin/awstats
+.pl?config=vhost.domain.co.nz
+</verbatim>
+
+!
!Extra reading
+
+* [Debian Administration article|http://www.debian-administration.org/articles/277]
+* [Debian awstats guide|http://ghaint.no-ip.org:8942/~k2/debian/awstats-debian.html]
+* [Configuring AWStats and Apache2 on Ubuntu|http://www.mneylon.com/blog/archives/2005/08/03/configuring-awstats-with-apache-2-on-ubuntu/]
+
-----
CategoryNotes