« Defining Alias InterfacesOpenLDAP Backtrace »

AWStats

08/18/04

Permalink 07:56:23 am, by admin Email , 531 words   English (US)
Categories: Apache, Install Notes

AWStats

AWStats
http://awstats.sourceforge.net/

Goal: Install AWStats 5.9 on a Sun Cobalt server and configure to auto
generate reports for all virtual domains hosted on the server.

Note: Also tested on FreeBSD 4.9-RELEASE with AWStats 6.1

1. Verify Apache version ...

> httpd -v
Server version: Apache/1.3.20 Sun Cobalt (Unix)
Server built:   Jul 23 2001 14:55:10

On FreeBSD used:

> /www/apache/bin/httpd -v
Server version: Apache/1.3.26 (Unix)
Server built:   Aug 27 2002 01:38:46

2. Verify shared module support ...

> httpd -l
Compiled-in modules:
  http_core.c
  mod_so.c
  mod_perl.c
suexec: enabled; valid wrapper /usr/sbin/suexec

On FreeBSD:

>/www/apache/bin/httpd -l
Compiled-in modules:
  http_core.c
  mod_so.c
suexec: disabled; invalid wrapper /www/apache/bin/suexec

In both cases we're looking for the presence of mod_so.c

3 . Download and unpack AWStats software ...

> cd /root
> mkdir archive
> cd archive
> wget http://unc.dl.sourceforge.net/sourceforge/awstats/awstats-5.9.tgz

FreeBSD was missing the wget command so I did the download like this:

> lynx -source http://unc.dl.sourceforge.net/sourceforge\
/awstats/awstats-6.1.tgz > awstats-6.1.tgz

Now unpack the distribution:

> tar -xvzf awstats-5.9.tgz
> cd awstats-5.9

or on FreeBSD: 

> tar -xvzf awstats-6.1.tgz
> cd awstats-6.1

4. Install AWStats software ...

> mv wwwroot /home/awstats
> cp tools/awstats_buildstaticpages.pl /home/awstats/cgi-bin

5. Install run script ...

> cd /root/archive
> wget http://www.reliablepenguin.com/clients/misc/awstats.run.pl

or on FreeBSD:

> lynx -source http://www.reliablepenguin.com/\
clients/misc/awstats.run.pl > awstats.run.pl

You might need to edit this script and adjust the SITE_BASE variable to match your install.

On FreeBSD the path to grep had to be changed to /usr/bin/grep at the start of the script.

Next do:

> chmod 755 awstats.run.pl
> cp awstats.run.pl /usr/local/sbin

6. Install config template ...

> cd /home/awstats/cgi-bin
> wget http://www.reliablepenguin.com/clients/misc/awstats.template.conf

or on FreeBSD:

> lynx -source http://www.reliablepenguin.com/\
clients/misc/awstats.template.conf > awstats.template.conf 

The template config file sets the following:

        LogFile="/home/sites/#SITE#/logs/web"

        LogType=W

        LogFormat=1

        SiteDomain="#SITE#"

        DNSLookup=0

        DirCgi="/awstats/cgi-bin"

        DirIcons="/awstats/icon"

For FreeBSD the template must be edited to set the following:

        LogFile="/www/logs/#SITE#-access.log"

7. Setup apache ....

Edit /etc/httpd/conf/httpd.conf and add the following lines
to the end of the file just before any virtual definitions:

   Alias /awstats/icon /home/awstats/icon
   Alias /awstats/js /home/awstats/js
   Alias /aswtats/css /home/awstats/css

On FreeBSD the httpd.conf file is located in /usr/www/apache/conf/

8. Setup logrotate ...

Edit /etc/logrotate.d/apache and add the indicated line.

        /var/log/httpd/access {
            prerotate
                /usr/local/sbin/split_logs web < /var/log/httpd/access
ADD -->         /usr/local/sbin/awstats.run.pl >> /var/log/awstats.log
            endscript
            missingok
            postrotate
                /usr/bin/killall -HUP httpd 2> /dev/null || true
            endscript
            daily
        }

The logrotate setup was not needed on the FreeBSD server. Instead a cronjob did the trick.

That does it!

Notes:
Basic awstats operations:

a. Initialize the database with logs ...

> /awstats.pl -config=your.domain -update

b. Run reports ...

> /home/awstats/cgi-bin/awstats_buildstaticpages.pl \
        -config=your.domain \
        -dir=/home/sites/your.domain/web/awstats/reports \
        -awstatsprog=/home/awstats/cgi-bin/awstats.pl

July 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Reliable Penguin offers Linux Server Migrations, Systems Administration & Programming. Visit our main website at:

http://www.reliablepenguin.com

Search

Bookmark and Share

XML Feeds

free blog software