SPECT Research Blog

Security and Software Development

Installing custom Trac in DreamHost using Passenger

| Comments

Dreamhost offers to install Trac through “One Click Installs”. The version offered by Dreamhost is 0.11.4, but current version is 0.12.3, which one has a lot of new features. In this post I will describe the steps to install successfully Trac 0.12.3 in Dreamhost.

I’ll be using PythonBrew to install a newer version of both Python and virtualenv. After you correctly installed PythonBrew, the steps to install Trac are the following ones:

1
2
3
4
5
6
pythonbrew install 2.7.3
python switch 2.7.3
pythonbrew venv create trac -n
pythonbrew venv use trac
pip install trac
pythonbrew cleanup

At this moment, you have installed Trac in your virtual environment. Now, you have to create your Trac project in some directory (in this case ~/trac/ ), and then deploy it to the directory related with the domain.

1
2
trac-admin ~/trac/ initenv
trac-admin trac deploy domain/

According to Passenger, you need to have a public directory and a passenger_wsgi.py file. The first one is a symbolic link to htdocs directory, and the second one you need to edit it.

1
2
3
4
cd domain/
rm -rf public
ln -s htdocs public
cp cgi-bin/trac.wsgi passenger_wsgi.py

In passenger_wsgi.py, you need to add the virtual environment path. The shebang of the file is the Python executable in our virtual environment. So, after the library imports, you need to add the following lines:

1
2
3
4
import sys

INTERP = "/home/user/.pythonbrew/venvs/Python-2.7.3/trac/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)

Now, you can enjoy Trac at your domain address!