installing trac on dreamhost
Installing Trac on Dreamhost takes a bit of work.
Disclaimer: This how to may kick your dog, eat your dinner, and cause the sky to fall...use at your own risk.
It has been a week or two since I actually performed the following steps, so I might have missed a tweak here or there that needs to be performed. If you run into issues with the following steps, just let me know. I probably ran into it to, but just forgot to list them.
Anyway..here we go...
Requirements:
- You are already ssh'ed into your dreamhost account
Note: We are going to be using the python that dreamhost has installed. I did this how-to with python 2.3, which is 'python' on dreamhost. I imagine it can be done with python2.4 as well. I have not tested it, however.
Setting up the Environment
Add the following to the bottom of your .bashrc, if it is not already there.
export PYTHONPATH=${HOME}/packages/lib/python
export PATH=${HOME}/packages/bin:$PATH
Add the following to the bottom of your your .bash_profile, if it is not already there.
export PYTHONPATH=${HOME}/packages/lib/python
export PATH=${HOME}/packages/bin:$PATH
Nothing like a little harmless duplication. ;)
Add the following to .pydistutils.cfg. This file likely needs to be created. It should reside in your home directory.
[install]
install_lib = /home/username/packages/lib/python
install_scripts = /home/username/packages/bin
Make sure to adjust the path's accordingly.
Create the 'packages' directory if you do not already have it.
$ mkdir ~/packages
Now just log out, and log back in, to pick up the new environment variables we just set. That is all the setup that we should need.
Installing Clearsilver
I loosely followed the Dreamhost Clearsilver Installation Guide to get Clearsilver installed. I had to adjust a few things, because I didn't want to install my own python version. I am piggy-backing off the Dreamhost python installation.
First, create a working directory.
$ cd ~
$ mkdir working
$ cd working
Then, fetch the source for Clearsilver.
$ wget http://www.clearsilver.net/downloads/clearsilver-0.10.2.tar.gz
$ tar zxf clearsilver-0.10.2.tar.gz
$ cd clearsilver-0.10.2
We need to fix a few things before we can start building..
$ sed -i "s@/usr/local/bin/python@/usr/bin/env python@g" scripts/document.py
$ PYTHON_SITE=/home/username/packages/lib/python
$ ./configure --prefix=/home/username/packages --disable-ruby --disable-java --disable-apache --disable-csharp --disable-perl
Adjust the path to your 'packages' directory as needed.
Now we can build it.
$ make
$ make install
Installing python setuptools
Download ez_setup.py
$ cd ~/working
$ wget http://peak.telecommunity.com/dist/ez_setup.py
Run it
$ python ez_setup.py
You should now have a working setuptools installation.
Installing Trac
Now we can go ahead and install Trac.
First, download the source.
$ cd ~/working
$ 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 --prefix=/home/username/packages
Again, adjust the path as needed.
Setting up a trac instance
Create a directory to hold trac sites.
$ cd ~
$ mkdir trac_sites
$ cd trac_sites
Now create a trac instace.
$ trac-admin mytracsite initenv
The above command will start asking you questions. When you are done, you should have a trac instance ready to work with.
Creating the cgi/fcgi runner
We have to create the cgi/fcgi runner for the trac site now.
Change to the directory that you want the trac instance served out of.
$ cd ~/my.domain.com
Now create a file named 'trac', and put the following in its contents.
#!/bin/bash
export TRAC_ENV="/home/username/trac_sites/mytracsite"
export PYTHONPATH=/home/username/packages/lib/python
export LD_LIBRARY_PATH=/home/username/packages/lib/
export PATH="/home/username/packages/bin:$PATH"
exec /home/username/packages/share/trac/cgi-bin/trac.cgi
The above works for cgi. To change to fcgi, change the last line to point to trac.fcgi
Now we need to tell apache how to handle the 'trac' file. Add this to the bottom of your .htaccess file in the current directory.
<Files trac>
SetHandler cgi-script
</Files>
For fastcgi, change cgi-script to fastcgi-script.
Now try accessing the url for your site.
Plugin Installation
I recommend using the following plugins:
- TracDBAuth
- TracWebAdmin
TracDBAuth will allow you to use a login page, instead of having to utilize the login hack outlined in the Dreamhost Trac Wiki. Since we have a local installation of setuptools, and we are using a piggy-back python from the main dreamhost python install, you can adjust the dreamhost wiki steps accordingly (basically, this means you don't need to use a path for python, just use 'python').
Speed Tweaks
Edit the trac.ini file, located in your ~/trac_sites/mytracsite/conf directory.
Add the following element under the '[trac]' section.
htdocs_location = /trac_resources/trac-htdocs
Copy the static trac htdocs from the share directory, to your web directory, and place them as needed.
$ cd ~/my.domain.com
$ mkdir trac_resources
$ cd trac_resources
$ cp -a ~/packages/share/trac/htdocs trac-htdocs
Now, whenever trac serves up one of the static elements in the site, it will simply hand this off to apache to server directly from that directory, instead of having to server it through the cgi script. Much faster (by almost a factor of 2 I would guess).
References
- Edgewall Trac
- Dreamhost Clearsilver Install Guide
- Dreamhost Trac Install Guide
- Trac installation guide
Addendum
- Added 2006-08-03: In a more recent post, I resolved a nagging issue I was having with trac and fastcgi on Dreamhost.