Install the Webalizer Webstat Tool

From OpenFSG
Revision as of 16:07, 24 January 2008 by Green Fig (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is how I managed to install the "Webalizer" which is, though outdated, one of the Standard Tools (almost) every Webmaster uses.


Preparations

0) Login as root using SSH

1) Make sure your Webserver has DNS lookup enabled. This is off by default (at least it was on my FSG)

vi /etc/templates/httpd.conf.template

(if you are of the scary type, create a backup of the template file!)

check if HostnameLookups is set to On if not, set it to On and uncomment the line if it has a trailing #

2) Make sure your Webserver's logging function is enabled. This ist also disabled by default (at least it was on my FSG)

Check in the httpd.conf.template if the line containing

TransferLog /logs/access_log

is uncommented! If there is a trailing # then remove it!

Save the file ...

3) STOP and RESTART your http-service or, better, reboot your FSG :-)

Going into it

Still being logged in as root, download the webalizer package

ipkg install webalizer

Webalizer and all its dependencies will be installed.

The executable can then be found in /opt/bin/webalizer while the configfile resists in /opt/etc/webalizer.conf.

Move the config file to /etc/webalizer.conf because the webalizer binary will look for it in /etc/webalizer.conf or set a link:

mv /opt/etc/webalizer.conf /etc/

Edit the config file:

vi /etc/webalizer.conf

These lines are most important:

LogFile /usr/local/apache/logs/access_log (where webalizer can find apache's logfile - you can change this path in the http.conf.template if you like, but don't forget to change it in the webalizer.conf accordingly)

OutputDir /home/webalize/ (where you want the statistics to be put; you will find a index.html there, maybe you would want to set up an alias in your webserver to point to this directory to be able to view your stats from wherever you are)

Uncomment most of the lines starting with HTML... because this is the setup for how the stats-page will look like. Delve a little deeper into it to customize the page using different titles etc. This is truly not hard.

Save the file.

Parsing the logfile

Tell webalizer to parse the apache logfile by entering:

webalizer

The output should look like this:

/ # webalizer
Webalizer V2.01-10 (Linux 2.4.27-uc1) English
Using logfile /usr/local/apache/logs/access_log (clf)
Creating output in /home/webalize/
Hostname for reports is '********.com'
Reading history file... webalizer.hist
Generating report for April 2007
Generating summary report
Saving history information...
993 records in 0.84 seconds''

Then check the file in e.g. /home/webalize (index.html) and smile :-)

You can add a cronjob to periodically parse the apache logfiles by editing the crontab (which can only be done via the file /etc/init.d/croninit because the crontab-file will be overwritten after each reboot!):

vi /etc/rc/S97croninit

Add this line right before the last line which says exit 0 (it will start the webalizer at midnight, every day):

echo "0 0 * * * root /opt/bin/webalizer" >> /etc/crontab

Then reboot and check your newly generated crontab by entering:

cat /etc/crontab

My result looks like this:

~ # cat /etc/crontab
0 * * * * root /etc/init.d/ntpupdate
0 0 * * * root /opt/bin/webalizer

Have fun!

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox