Clickstream Logging with Apache 2 mod_cookietrack

Continue with yesterday installation step but using the mod_cookietrack module instead. Installation steps as follows:

1. Check out the source code from github repository.
$ git clone

2. First determine the type of Multi-Processing Modules (MPM) used. As shown below, in my Ubuntu 12.10, the default Apache is using Prefork MPM.
$ $ sudo apachectl -V | grep MPM
Server MPM:     Prefork
 -D APACHE_MPM_DIR="server/mpm/prefork"

3. Find the necessary, in this case, prefork related development library because to compile the module. As the development package will provide us with apxs, Apache eXtension tool.
$ sudo apt-cache search prefork | grep apache2 | grep dev
apache2-prefork-dev - Apache development headers - non-threaded MPM

4. Install the required packages
$ sudo apt-get install apache2-prefork-dev perl

5. Before we can compile the module, change the shebang (first line of the script) as the path is wrong. Otherwise the script will not run. Amend the first line to :
$ vi
#!/usr/bin/env perl

We use /usr/bin/env instead of direct full path /usr/bin/perl for portability. See shebang for further explanation.

6. Make the script executable and run it.
$ chmod +x
$ sudo ./

7. Our module and the configuration file will be installed in following locations.

8. For testing purpose, we need to install node.js to create a sample node server. We also need to change the test/run_backend.js script to rename node to nodejs. Ubuntu 12.10 default packages uses different binary name.
$ sudo apt-get install nodejs
$ vi test/run_backend.js
nodejs test/server.js

$ test/

9. Open a new terminal. Start a new customer Apache daemon. However, if your follow the original installaton instruction, you will encounter this error.
$ sudo test/
$ tail -f test/error.log
[Sun Feb 03 01:01:05 2013] [alert] (22)Invalid argument: setgid: unable to set group id to Group 4294967295

The error is due to missing group id in the test/http.conf file. We will add this in.
$ vi test/httpd.conf
User www-data
Group www-data

10. Open another terminal to run the test suite. The --debug flag will dump all the HTTP request and response content.
$ perl test/
$ perl test/ --debug

11. Open another terminal to monitor the error log.
$ tail -f test/error.log

12. Since this module is a enhancement and replacement for mod_usertrack, all the mod_usertrack's configuration options should work seamlessly. Hence, we need to disable the mod_usertrack module we setup in previous post.
$ sudo a2dismod usertrack
$ sudo apachectl restart

No comments:

Post a Comment