Penguin
Blame: AwStatsNotes
EditPageHistoryDiffInfoLikePages
Annotated edit history of AwStatsNotes version 4, including all changes. View license author blame.
Rev Author # Line
2 CraigBox 1 !!!Debian/Ubuntu AWStats virtual host setup
1 CraigBox 2
3 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>.
4
2 CraigBox 5 !! Configuring Apache
1 CraigBox 6
2 CraigBox 7 Drop this in /etc/apache2/conf.d/awstats:
1 CraigBox 8 <verbatim>
9 Alias /awstats-icon/ /usr/share/awstats/icon/
10
11 <Directory /usr/share/awstats/icon>
12 Options None
13 AllowOverride None
14 Order allow,deny
15 Allow from all
16 </Directory>
17 </verbatim>
18
2 CraigBox 19 !! Configuring AWStats
1 CraigBox 20
21 For each vhost you want to analyse, create a /etc/awstats/awstats.vhost.domain.co.nz.conf file, looking like such:
22
23 <verbatim>
24 LogFile="/var/www/vhost.domain.co.nz/log/access.log"
25 LogType=W
3 CraigBox 26 LogFormat=1
1 CraigBox 27 LogSeparator=" "
28 SiteDomain="vhost.domain.co.nz"
29 HostAliases="localhost 127.0.0.1"
30 DNSLookup=1
31 DirData="/var/lib/awstats"
32 DirCgi="/cgi-bin"
33 DirIcons="/awstats-icon"
34 AllowToUpdateStatsFromBrowser=0
35 AllowFullYearView=2
2 CraigBox 36 LoadPlugin="geoipfree"
1 CraigBox 37 </verbatim>
3 CraigBox 38
4 CraigBox 39 Use <tt>~LogFormat 1</tt> if you are using 'combined' Apache logs, which are used by default. Use <tt>~LogFormat 4</tt> otherwise
1 CraigBox 40
2 CraigBox 41 !!Updating the page
42
43 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:
44
45 <verbatim>
46 /var/www/vhost.domain.co.nz/log/*.log {
47 daily
48 missingok
49 rotate 7
50 compress
51 delaycompress
52 notifempty
53 create 640 www-data www-data
54 prerotate
55 /usr/lib/cgi-bin/awstats.pl -config=vhost.domain.co.nz -update
56 endscript
57 }
58 </verbatim>
59
60 You could put a cron fragment like this somewhere:
61
62 <verbatim>
63 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
64 </verbatim>
65
66 !!Password protect your stats
67
68 We will use Apache's .htaccess mechanism to ensure you can only see the stats if you know a password.
69
70 <tt>htpasswd -c /etc/awstats/awstats.htpasswd ''username''</tt>
71
72 Now, edit /etc/apache2/sites-enabled/000-default, under ''<Directory "/usr/lib/cgi-bin">'', add
73
74 <verbatim>
75 AuthType basic
76 AuthName "cgi-bin restricted"
77 AuthUserFile /etc/awstats/awstats.htpasswd
78
79 <Files awstats.pl>
80 Require valid-user
81 </Files>
82 </verbatim>
83
84 Reload Apache, and try navigating to http''''://primary.sitename.co.nz/cgi-bin/awstats.pl?config=vhost.domain.co.nz.
85
86 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:
87
88 <verbatim>
89 RedirectMatch permanent /stats http://primary.sitename.co.nz/cgi-bin/awstats
90 .pl?config=vhost.domain.co.nz
91 </verbatim>
92
93 !!Extra reading
94
95 * [Debian Administration article|http://www.debian-administration.org/articles/277]
96 * [Debian awstats guide|http://ghaint.no-ip.org:8942/~k2/debian/awstats-debian.html]
97 * [Configuring AWStats and Apache2 on Ubuntu|http://www.mneylon.com/blog/archives/2005/08/03/configuring-awstats-with-apache-2-on-ubuntu/]
98
1 CraigBox 99
100 -----
101 CategoryNotes