Saturday, December 13, 2008

Install Webalizer on Gentoo and use Cron

Webalizer is a program that analyses your apache webserver log and generates webpages complete with graphs of the traffics.

It's a little bit more difficult to install than logrotate. Start by emerging webalizer, which will install the files on your computer.

# emerge -av webalizer

Currently the text messages after installing webalizer are a bit outdated, contrary to what it says don't add anything to the apache.conf file, apache2 already will read the config file for webalizer because it's in the /etc/apache2/conf/modules.d directory. But you do need to restart apache to get webalizer to work:

# /etc/runlevels/default/apache2 restart

If you look at http://localhost/webalizer you will still see nothing, this is because no stat files have been generated yet. Create a new file called webalizer.cron (such as the cron.daily directory, if you want updated stats to build each night).
File: /etc/cron.daily/webalizer.cron

#! /bin/sh
/usr/bin/webalizer

Now you have created the file, but you must also make it executable in order for cron to be able to run it.

# chmod +x /etc/cron.daily/webalizer.cron

To test that it's executable, and to generate your first stats you just run the program. Do this by typing in its name:

# /etc/cron.daily/webalizer.cron

You will see some output from webalizer that it generates the information, and you can now visit your local computer under the http://localhost/webalizer and see your stats.

Edit /etc/webalizer.conf:
LogFile /var/log/apache2/access_log
OutputDir /home/webmaster/www/domain.tld/webalizer/

No comments:

Post a Comment