Forum Moderators: phranque

Message Too Old, No Replies

setting up webalizer and virtual hosts

does each virtual host need separate log files?

         

jamie

1:01 pm on Jan 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi,

we're just setting up our redhat / apache server with virtual hosts. i am about to install the webalizer-rpm so that each client can see their own stats.

at the moment all virtual hosts log to the same log files:

TransferLog logs/access_log
ErrorLog logs/error_log

can i leave it like that and simply install webalizer and webalizer will sort out which parts of which logs go with each virtual host?

or will i need to manually add the following to httpd.conf

LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog logs/access_log combined

many thanks :)

p.s. why exactly is the CustomLog directive needed? is that to combine all of the above LogFormats?

seindal

7:59 pm on Jan 28, 2003 (gmt 0)

10+ Year Member


If you have only a few virtual hosts you can just let each have its own log file and run webalizer separately for each vhost.

If you have many you will probably have to have a single log file, which you them split before running webalizer for each site.

In that case you need a directive like

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %v" full

The last %v inserts the name of the virtual host in the log entry.
Then make a single log file for all sites with

CustomLog /var/log/apache/custom.log full

in the global part of httpd.conf.

Then use a script like the following to split the log file into separate files, one for each vhost.

--------------------------
#!/usr/bin/perl -w

use strict;
use warnings;

-d 'logs' or mkdir 'logs';

my %fds;

while (<>[smilestopper]) {
chomp;
my @x = split;
my $site = pop @x;

my $fd = $fds{$site};
unless (defined $fd) {
#print STDERR "OPEN $site\n";

open($fd, ">>logs/$site"[smilestopper]) or next;
$fds{$site} = $fd;
}

print $fd "$_\n";
}
-------------

after this the logs directory contains several files, one for each vhost. Feed these to webalizer.

René.

jamie

3:31 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thank you rené

might take a while to get my head round this ;) but much obliged!

seindal

4:41 pm on Jan 29, 2003 (gmt 0)

10+ Year Member



Well, to cut it down to the basics there are three steps

1. make a single log file that includes the vhost name

An to generate the stats:

2. split that log file into separate files for each vhost
3. run webalizer on each file.

jamie

5:01 pm on Jan 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi rené,

this is a bit off topic, but i have just run rpm -i webalizer and it says failed dependancies:

webserver is needed by webalizer-2.01_09-1.72

? how can this be, as apache is installed and working. or does this mean something else?

thanks

seindal

5:25 pm on Jan 29, 2003 (gmt 0)

10+ Year Member



We need a Redhat guru for this. I'm a Debian man. We don't have dependency problems :-)

Any Redhat users willing to help here?

René.

David

4:17 pm on Jan 30, 2003 (gmt 0)

10+ Year Member



Not sure if its part of RH 7.2 but I would try ..

up2date webalizer

jamie

4:57 pm on Jan 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi david,

thanks for the tip. i did it and it installed webalizer and apache-1.3.27-1.7.2.i386.rpm as well.

when i did a search for 'webserver' at rpmfind it returned exactly this apache package, but i know we already had apache installed and i didn't want to touch that.

but obviously the system knows best :-)

i guess its me coming from windows background where installing and uninstalling is rather inaccurate science ;-)

now i can get on splitting and combining the logs rené.

i'll get back to you if i run into trouble

thanks both!

seindal

5:00 pm on Jan 30, 2003 (gmt 0)

10+ Year Member



You're welcome.

I get a mail when this thread is updated, so just post here.

René.