Wednesday, September 16, 2015

How to extract the monthly report of an Apache log file

To extract the monthly report of an Apache log file, use the Linux sed command.  For example, to get the logs from July 1, 2015 to July 31, 2015, issue the command:

# sed -n '/1\/Jul\/2015/,/31\/Jul\/2015/ p' /opt/lamp/logs/access.log > Jul2015_log


Installing Webalizer on Ubuntu 14.04

Webalizer is a web-based log file viewer.  To install the software on Ubuntu 14.04, type:

# apt-get install webalizer 

This will install the software in default location. The configuration file is in /etc/webalizer and the default web pages will be created in /var/www/webalizer directory.

The command of the webalizer is:

#/usr/bin/webalizer

Edit the webalizer.conf in the /etc/webalizer directory to point to the Apache log file location (e.g., /var/log/apache2/access_log) and issue the command #/usr/bin/webalizer to create the log file HTML in /var/www/webalizer directory.

To execute the webalizer command at regular intervals, use the Linux's crontab command.