Installing and configuring mod_wsgi
Now, the server is ready for mod_wsgi. Since there is no package for this in Ubuntu 7.10, we need to get it directly from the download site:
$ wget http://modwsgi.googlecode.com/files/mod_wsgi-2.0c4.tar.gz $ tar xzf mod_wsgi-2.0c4.tar.gz $ cd mod_wsgi-2.0c4 $ ./configure --with-python=/usr/bin/python2.4 $ make $ make install
Note that it is necessary to compile mod_wsgi using the same Python you will use to run your web site. Since Zope requires 2.4, the --with-python option was used to point to the newly installed Python.
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 inside the mods-available directory.
The load declaration was put on a file named wsgi.load, which contains only this:
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
The configuration directives reside in the file named wsgi.conf, they contain an almost identical configuration to the one shown on the repoze.org site, on the deployment page. Replace ${sandbox} below with the path to your Repoze installation's top-level environment.
WSGIPythonHome ${sandbox}
WSGIDaemonProcess tmp threads=1 processes=4 maximum-requests=10000 python-path=${sandbox}/lib/python2.4/site-packages
<VirtualHost *:80>
ServerName my.machine.local
WSGIScriptAlias /site ${sandbox}/bin/zope2.wsgi
WSGIProcessGroup tmp
WSGIPassAuthorization On
SetEnv HTTP_X_VHM_HOST http://my.machine.local/site
SetEnv PASTE_CONFIG ${sandbox}/etc/zope2.ini
</VirtualHost>
This will run mod_wsgi in 'daemon' mode, which means it will launch a number of processes to run the configured WSGI application instead of using the Apache process. Since Repoze uses virtualenv, the site-packages directory of the virtual Python used to run it needs to be passed in the python-path variable. To tell mod_wsgi which WSGI application to run, we use the WSGIScriptAlias directive and pass it the path to the desired application.
To really activate this configuration files, another step is required, which is to create soft links for them under the mods-enabled directory of the Apache configuration:
$ cd mods-enabled $ ln -s ../mods-available/wsgi.load $ ln -s ../mods-available/wsgi.conf
For apache 1.3 or Apache 2 with an old directory layout, you may need to put both of these snippets inside the httpd.conf file in your Apache's /etc directory. The soft links above will not be necessary in that case.