Trac on Dreamhost

I am working on launching a little project, and thought about using Trac to manage the development. This is the first time I am setting up Trac, and given that people seem to be having lots of problems installing Trac on Dreamhost I figured this would be a painful experience.

First I created the and sites, and I think I actually made the installation of Trac simpler because of this. Another option would have been, which I believe would make some of the later steps harder. I also used the Dreamhost Panel to create the Subversion repository at

First of all, there is a nice script for making Trac install nearly painless on Dreamhost. Unfortunately the script is hardcoded to use the system Python 2.3, and at least one of the plugins the script installs is not compatible with 2.3. I found this out by installing, then changing the admin preferences by adding an email address which completely broke the installation: any URL would just result in a Python stack trace.

Which reminds me that I find it really strange that Trac is giving the full stack traces in the web UI; that is a security problem. Pylons for example does that only in the development mode by default, and in production mode the default puts errors only in the log (and it can also email the error to administrator if email is set up). After brief search I have not seen a way to stop the stack traces from appearing in the web UI.

I then figured I’d install Trac the hard way, by hand. How hard could it be, right?

First I needed to set up some prerequisites as was described in the official Trac installation guide (some of these at least might be installed automatically by setuptools, but I installed what I wanted in advance). I had installed Python 2.5 earlier, so that was no problem. SWIG was already high enough version so I didn’t need to do anything about that. I figured I wouldn’t need Clearsilver or SQLite. First I installed setuptools, then it was trivial to install python-mysql (mysql was already on the system), genshi, docutils, pygments and pytz. Naturally Apache was already provided by Dreamhost as well, but even though Subversion was provided I also needed to build one myself to get the Python bindings for 2.5. To make managing the repository easier, I chose to install the exact same Subversion as was the system wide version; that way I could use the Dreamhost Panel to manage the repository and give Trac access to it as well. Of course, if Dreamhost ever updates its version I will be in trouble… The build and installation were a breeze with good instructions. Finally easy_install Trac went through without a hitch. I also installed Account Manager plugin which turned out to be a mistake.

Then came a pretty hard part; how to create a Trac site. I adapted pieces of the easy Trac install script into my own setup, and managed to use trac-admin to create my site. I was also able to serve it with tracd, but this is good only for testing. Next I tried to figure out how to serve Trac as CGI. I was stopped cold by not finding the cgi-bin directory that was mentioned in the instructions. After a bit of fumbling and doing web searches I figured out how to use trac-admin deploy command (trac-admin /path/to/trac/env deploy /path/to/dump/cgi-bin-etc).

Next step was putting in the index.cgi and .htaccess files. I started from what the script install used, but it turned out all I really needed for index.cgi was:

export TRAC_ENV="/path/to/trac/env"
export PATH=/path/to/python2.5/bin:$PATH
exec /path/to/cgi-bin/trac.cgi

The cgi file naturally needs to be executable.

You will also need to make trac.cgi executable, and change the hash bang line to /usr/bin/env python – the default will pick up the old system Python. Note that trac.cgi will output stack trace to the web in case of error, so you should take out the line that does that and leave just the line that prints into log.

The last struggle was with .htaccess, which turned out like so (you may want to modify this to allow the Dreamhost stats gathering of your site):

DirectoryIndex index.cgi
Options ExecCGI FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cgi/$1 [L]

Oh, lest I forget, I also created the admin user, admins group, and the default password for the admin using the procedure described in the easy Dreamhost installation script.

After this I was able to browse the Trac site fine. I logged in as administrator and changed the password. Then I made the mistake of putting in an email address for the administrator. Apparently (?) due to the Account Manager plugin the admin account was made limited until email verification was completed. The problem was that I had not set up outgoing email yet. And then I made another error by clearing the admin email, which resulted in getting a stack trace on every page while logged in.

I’ve since set up outgoing email, which proved simple by using a GMail account. But the admin account is still hosed, and I am too tired to figure that out right now.

Similar Posts:

    None Found