Edgewall Software

Trac on Ubuntu 5.10 using workingenv and fcgi

This howto covers some of the process of installing Trac on Ubuntu 5.10 using Ian Bicking's workingenv tool, and CGI or FCGI.

Make sure you have the fcgi module enabled:

$ sudo a2enmod fastcgi

Download workingenv:

$ wget http://svn.colorstudy.com/home/ianb/workingenv/workingenv.py

Set up a working environment in /usr/local/trac:

$ sudo python workingenv.py /usr/local/trac

Assuming you are in the admin group, make it group-owned by admin, and group-writeable, so you can install software into it:

$ sudo chgrp -R admin /usr/local/trac
$ sudo chmod -R g+w /usr/local/trac

Change to the /usr/local/trac directory and activate its environment:

$ cd /usr/local/trac
$ source bin/activate

As of this writing, there is a shortcoming in workingenv that requires you to create another .pth file for certain types of package installs, one of which is Trac:

$ echo site-packages > lib/python2.4/sitepackages.pth

Also, the latest version of setuptools checks the first line of lib/site.py for a function definition. Edit the lib/python2.4/site.py file and remove the first line, which should be a comment. The first line should now begin with "def boot():". Install enscript, for syntax highlighting:

$ sudo apt-get install enscript

Download the latest release of Trac and install it. Note that it is not installable using easy_install (at least last time I tried using 0.9.4), so use the traditional method:

$ cd src
$ wget http://ftp.edgewall.com/pub/trac/trac-0.9.5.tar.gz
$ tar xzf trac-0.9.5.tar.gz
$ cd trac-0.9.5
$ python setup.py install

Chances are, you'll want the web admin plugin installed as well. Refer to the WebAdmin page for more information. Here's how I installed the version for Python 2.4 and Trac 0.9.3:

$ cd ..
$ wget "http://projects.edgewall.com/trac/attachment/wiki/WebAdmin/TracWebAdmin-0.1.1dev_r2765-py2.4.egg.zip?format=raw"
$ mv "TracWebAdmin-0.1.1dev_r2765-py2.4.egg.zip?format=raw" TracWebAdmin-0.1.1dev_r2765-py2.4.egg
$ easy_install TracWebAdmin-0.1.1dev_r2765-py2.4.egg

Finally, it's useful to have docutils installed in case you want to use reStructuredText:

$ easy_install -i http://cheeseshop.python.org/pypi docutils

Now rename the trac.cgi and trac.fcgi files, so we can put a shell script in its place that activates the working environment upon invocation:

$ cd ../share/trac/cgi-bin
$ mv trac.cgi _trac.cgi
$ mv trac.fcgi _trac.fcgi

Create the new trac.cgi and trac.fcgi scripts as shown here:

#!/bin/sh
# trac.cgi
source /usr/local/trac/bin/activate
/usr/local/trac/share/trac/cgi-bin/_trac.cgi $@

#!/bin/sh
# trac.fcgi
source /usr/local/trac/bin/activate
/usr/local/trac/share/trac/cgi-bin/_trac.fcgi $@

Make the scripts executable:

$ chmod +x trac.*cgi

Now you can proceed with normal Trac instance creation, and configuration of the web server.

Just remember, whenever you need to be able to call trac-admin, you'll need to type this into the shell first:

$ source /usr/local/trac/bin/activate

If you no longer want to use the working environment in the current shell, run the "deactivate" command.

If you need to run operations as root, remember that the working environment doesn't pass through sudo. So, use sudo to get a root shell instead:

$ sudo su
# source /usr/local/trac/bin/activate