[HOWTO] Log Apache to MySQL on Ubuntu 8.04 (Hardy Heron)

Print this post Email this post

Installing the Software
Run the following commands in terminal:

sudo apt-get update
sudo apt-get install libapache2-mod-log-sql-mysql libapache2-mod-log-sql libapache2-mod-log-sql-ssl

Create DB & User
Run the following commands in MySQL:

CREATE DATABASE apachelogs;
GRANT INSERT,CREATE ON apachelogs.* 
  TO apachelogger@localhost 
  IDENTIFIED BY 'insert_passwd_here';
FLUSH PRIVILEGES;

Add Entry to apache2.conf
Add the following entry to apache2.conf before the VirtualHost settings (commonly before

Include /etc/apache2/sites-enabled/

):

LogSQLLoginInfo mysql://apachelogger:insert_passwd_here@localhost/apachelogs
LogSQLCreateTables on
LogSQLDBParam socketfile /var/run/mysqld/mysqld.sock
LogSQLTransferLogFormat AabfHhmRSsTUuvI

Modify Each Virtual Host
For each virtual host that you want to log to SQL, add the following line:

LogSQLTransferLogTable this_site_com

where access_log is replaced by any table name; to differentiate many different virtual host, you can use the name of each virtual host here by replacing each dot (‘.’) with underscore (‘_’)

Be Sociable, Share!

Tags: , , , , ,

Leave a Reply

You must be logged in to post a comment.