Lighttpd install and configure Webalizer statistics software

by on August 21, 2006 · 7 comments· LAST UPDATED December 18, 2007

in , ,

Lighttpd logo

If you are new to Lighttpd, please see how to install and configure Lighttpd web server.

The Webalizer is a fast, free, web-server log files analysis program. It produces highly detailed, easily configurable usage reports in HTML format, for viewing with a standard web browser.
Statistics commonly reported by Webalizer include: hits; visits; referers; the visitors' countries; and the amount of data downloaded. These statistics can be viewed graphically and presented by different time frames, such as per day, hour, or month.

Install Webalizer

If you are using Fedora Core or Cent Os, type the following command to install
# yum install webalizer

If you are using Debian Linux Os, type the following command to install
# apt-get install webalizer

Webalizer configuration

Let us see how to configure Webalizer for the domain theos.in:

  • Domain name: theos.in
  • Webroot: /home/lighttpd/theos.in/
  • Webalizer Webroot: /home/lighttpd/theos.in/stats
  • Webalizer Reports directory: /home/lighttpd/theos.in/stats/out
  • Webalizer configuration file: /home/lighttpd/theos.in/stats/webalizer.conf
  • Webalizer state log file: /home/lighttpd/theos.in/stats/webalizer.current (This file stored incremental processing state for logs. This is useful for large sites that have to rotate their log files more than once a month [using logrotate] )
  • Webalizer the history file: /home/lighttpd/theos.in/stats/webalizer.hist (keeps the data for up to 12 months worth of logs i.e. you will be able to see last 12 months stats)
    Lighttpd log file location: /var/log/lighttpd/theos.in/access.log

To configure Webalizer, copy /etc/webalizer.conf file to your webroot/stats directory. Type the following commands:
# mkdir -p /home/lighttpd/theos.in/stats
# cp /etc/webalizer.conf /home/lighttpd/theos.in/stats/webalizer.conf

Now open /home/lighttpd/theos.in/stats/webalizer.conf file:
# vi /home/lighttpd/theos.in/stats/webalizer.conf

Setup LogFile location:
LogFile /var/log/lighttpd/theos.in/access.log

Make sure LogType is set to Lighttpd’s Combined web server log format:
LogType clf

Setup statistics report directory where you want to put the output files:
OutputDir /home/lighttpd/theos.in/stats/out

Setup the name of the history file:
HistoryName /home/lighttpd/theos.in/stats/webalizer.hist

Make sure you get stats for last 12 months:
Incremental yes

Specify the filename for saving the incremental data:
IncrementalName /webroot/home/lighttpd/theos.in/stats/webalizer.current

Define the hostname of report:
HostName theos.in

Setup DNSCache file name. Use the same file name for all your domains. This will speed up DNS name lookup (you need to create a directory /var/cache/webalizer):
DNSCache /var/cache/webalizer/dns_cache.db

To get accurate stats you need to hide your own site from stats:
HideSite theos.in

In addition, you need to hide your own site from referrals as it gives most referrals:
HideReferrer theos.in

Save and close the file.

Create a directory to store DNS cache file:
# mkdir -p /var/cache/webalizer

Generate test stats:
$ webalizer -c /home/lighttpd/theos.in/stats/webalizer.conf

Map /home/lighttpd/theos.in/stats/ directory to url:
Since /home/lighttpd/theos.in/stats directory is out of your default webroot (/home/lighttpd/theos.in/html) you will not able to see the stats by visiting url http://theos.in/stats/. You can take the help of Lighttpd's mod_alias to map urls. Open your configuration file and type following line:
# vi /etc/lighttpd/lighttpd.conf
Append following config directives:
alias.url = (
"/stats/" => "/home/lighttpd/theos.in/stats/out/"
)

Save and close the file. Restart the Lighttpd server:
# /etc/init.d/lighttpd restart

View your stats by visiting http://yourdomain.com/stats/ url . Here is sample stat from my own personal website (Click to enlarge images):

Lighttpd Webalizer stats # 1

Lighttpd Webalizer stats # 2

Lighttpd Webalizer stats # 3

Security

Since your log contains lots of personal information of your visitors (such as IP address, Search string query and much more), it is a good idea to put statistic folder/directory in a password protected directory.

Rotating log files

Finally, you need to configure logrotate to rotate logs files with Lighttpd

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 7 comments… read them below or add one }

1 Deepak October 7, 2007 at 1:35 pm

Hi,

How can I configure webalizer on one server for
multiple domains.

Thank you.

Regards,
Deepak

Reply

2 Eric December 13, 2007 at 6:50 pm

when installing webalizer with yum there is a dependency for httpd. is there a way to install webalizer without httpd?

Reply

3 nixCraft December 13, 2007 at 7:24 pm

Eric,

a) Easy solution – Just turn off httpd service

b) Get webalizer source code compile and install

c) Modify webalizer SRPM and remove httpd dependency

d) You can forcefully uninstall httpd after webalizer, I think rpm -e –force –nodeps is the option (read the rpm man page)

Reply

4 hide ip December 18, 2007 at 3:17 pm

How i can rotate log with webalizer and lighttpd?

Reply

5 nixCraft December 18, 2007 at 7:09 pm

Hide_ip,
Go here for rotating log with webalizer and lighttpd.

Reply

6 Isaak December 16, 2008 at 4:32 pm

Just some words about WebAlizer…

I don’t like it very much.
It’s rather good and does’t cost anything.
BUT:
1) the stats it gives is incorrect very often
2) some logs of WA are ref spamed, what may cause even DDOS of the site

But its not difficult to tune WA that way so it will work correctly!

Reply

7 Greg October 23, 2009 at 2:53 am

can Webalizer be configured in any way to send a detailed report via sendmail on a weekly basis?

Reply

Leave a Comment

Tagged as: , , , , , , , , , , ,

Previous post:

Next post: