Personal tools
You are here: Home Documentation Tutorials Installing and setting up Grok under mod_wsgi Installing and configuring mod_wsgi

Installing and configuring mod_wsgi

mod_wsgi is installed the same way as any Apache module
Grok can run behind any WSGI server. This tutorial will show how to install Grok behind the Apache web server and mod_wsgi on a brand new Linux virtual server.
Page 4 of 5.

Now, the server is ready to install mod_wsgi. There is a package libapache2-mod-wsgi on Ubuntu, but it's recommended to build the latest version, in part because mod_wsgi has to be compiled with the same Python used by Grok. Please remove the libapache2-mod-wsgi package if you have previously installed it. We need to get the source directly from the download site and build it:

$ wget http://modwsgi.googlecode.com/files/mod_wsgi-2.6.tar.gz
$ tar xzf mod_wsgi-2.6.tar.gz
$ cd mod_wsgi-2.6
$ ./configure --with-python=/usr/bin/python2.5
$ make
$ sudo make install

Again, note that it is necessary to compile mod_wsgi using the same Python you will use to run your web site. Since Grok requires 2.5, the --with-python option was used to point to the version of Python we need.

Once mod_wsgi is intalled, the apache server needs to be told about it. On Apache 2, this is done by adding the load declaration and any configuration directives to the /etc/apache2/mods-available/ directory.

The load declaration for the module needs to go on a file named wsgi.load (in /etc/apache2/mods-available/ directory), which contains only this:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

The configuration directives reside in the file named wsgi.conf next to wsgi.load. We don't create it now, but it can be useful later to add directives in it if you have more than one WSGI application to serve.

Then you have to activate the wsgi module with:

# a2enmod wsgi

Note: a2enmod stands for "apache2 enable mod", this executable create the symlink for you. Actually a2enmod wsgi is equivalent to:

# cd /etc/apache2/mods-enabled
# ln -s ../mods-available/wsgi.load
# ln -s ../mods-available/wsgi.conf # if it exists

For apache 1.3 or apache 2 with an old directory layout, you may need to put the LoadModule line and the configuration directives you will see later inside the httpd.conf file in your apache's /etc directory. The soft links above will not be necessary in that case.