Woot - Trac up and running

Here at work we've been using Subversion since I joined. There was no version control in place and it was the first change I made.

For some time now I've wanted to get Trac up and running as I've seen it in action, and it's integration with Subversion is nothing short of astounding.

Due to lack of time and resources, and because I heard Trac was a killer to set up on Windows, we went with Ray Camden's Lighthouse as our bug tracker until I could find a spare day or two.

Well today I finally decided to bite the bullet and install Trac. And you know what, in about 30 mins, it was up and running... and even then most of that was downloading files.

In fact, the only complication I had was forgetting to edit trac.cgi to find the python.exe file.

So, whilst not an extensive guide to getting Trac installed here's what I did.

Files to Download

Bear in mind I already had Subversion up and running with Apache on Windows 2003, so I won't be covering this step

  1. Python
  2. Subversion Python Bindings
  3. PySQLite
  4. Clearsilver
  5. Trac

Installation Notes

  • Install Python - You must use Python 2.3.x - the Subversion bindings are not available for Python 2.4
  • Copy the libsvn and svn folders in the Python Bindings to <python>\lib\site-packages
  • Install PySQLite
  • Extract neo_cgi.pyd from your Clearsilver download to <python>\lib\site-packages
  • Install Trac

Configuration

  • Copy <python>\share\trac\cgi-bin\trac.cgi to <apache>\cgi-bin
  • Edit the trac.cgi file so that the first line points to your python.exe file

Configure Trac DB

d:\python23>;python scripts\trac-admin d:/svn/trac.db

Initialise DB

Trac [d:/svn/trac.db]> initenv

Trac will now ask you for a Project Name, Database Connection String, Subversion Repository, and the Path to Templates

So as an example:

Project Name: Creative

Connection String: (just hit enter to accept default)

Subversion Repository: d:\svn\creative

Path to Templates: (just hit return)

Add Administrative Permissions

Trac [d:/svn/trac.db]> permission add admin TRAC_ADMIN

Add Trac to Apache

Edit httpd.conf:

# TRAC
Alias /trac "d:/Python23/share/trac/htdocs"

<Location /cgi-bin/trac.cgi>
SetEnv TRAC_ENV "d:/svn/trac.db"
SetEnv PYTHONPATH "d:/Subversion/bin"
# if you are running Apache as a user other than System, the TMP variable
# needs to be set to a place where that user can write scratch files. Make
# sure that this directory is created and writable by that user.
# SetEnv TMP "d:/svn/trac.db/tmp
</Location>

<Location /cgi-bin/trac.cgi/login>
AuthType Basic
AuthName "
Creative"
AuthUserFile passwd
Require valid-user
</Location>

<Directory "d:/Python23/share/trac/htdocs">

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Now you want to restart Apache.

Finally, hit http://yourdomain/cgi-bin/trac.cgi and log in via the username/password combinations you have set up in "passwd" for accessing Subversion.

Final Words

I know I've not covered everything, and I've certainly not mentioned any error messages you may potentially come across, but if you do have any issues, leave a comment here and I'll try and help out.

Related Blog Entries

Comments

Christian Ready's Gravatar This is great news! I just got done listening to CFWeekly and I thought I was going to have to find a Linux box to do all of this on. One question, though. Are you running apache 2.0 or a more recent version of Apache? I found I could only get SVN to work with Apache 2.0.x.

I ask because I don't want to pull my hair out trying to get Trac to work only to find that I'm using the wrong version of Apache.
# Posted By Christian Ready | 24/08/06 05:00

Andy Allan's Gravatar Currently running 2.0.54 ... I'm sure there was a mention of some sort of complication if trying to use 2.2 - I'll see if I can dig out that it was.
# Posted By Andy Allan | 24/08/06 10:24

Stephen Moretti's Gravatar I think Apache 2.2 is still considered to be bleeding edge and not really production ready, so probably best to use 2.0.58. Of course, I could be completely wrong. ;)
# Posted By Stephen Moretti | 24/08/06 10:59

Andy Allan's Gravatar Yes, you are wrong Moretti ... Or should I call you Jeanette :p (inside joke)
# Posted By Andy Allan | 24/08/06 11:41

Christian Ready's Gravatar Ok, sounds good. I'm glad I'm using the right version of Apache, then :)
# Posted By Christian Ready | 24/08/06 15:22

Rob Wilkerson's Gravatar I recently brought my organization up on Trac+Subversion on a Linux box and, I have to say, it might be the first application in history to be an easier on Linux than on Windows. I consider myself a Linux enthusiast, but I'm nowhere close to being an expert. I just installed Apache (of course), Subversion and Trac through the yum RPMs and everything just worked. I'm not sure I can say that's ever happened for me in a linux environment.

To share some of what I've learned, the only Apache conflict is on Windows. My Linux install is running on Apache 2.2.2 just fine. From what I understand, the Windows mod_python release doesn't play nice with Apache 2.2.x on Windows yet.

This is a great system. I love Subversion (we were using VSS) and Trac has been a huge productivity tool. Even removing the integrated ticketing from this thought, the wiki availability for collaborative documentation is outstanding. I couldn't be happier with what we've gotten out of it in just a few short weeks.
# Posted By Rob Wilkerson | 25/08/06 13:09

pinxo's Gravatar That does not work on my apache 2.2.3, I get this error:
access to /trac/myproject/login failed, reason: require directives present and no Authoritative handler.

Any hints?
# Posted By pinxo | 08/11/06 12:05

Andy Allan's Gravatar The Subversion bindings linked to above do not work with Apache 2.2 ... it states that on the bindings download page :)
# Posted By Andy Allan | 08/11/06 12:19

pinxo's Gravatar Everything works fine, I just forgot to enable the apache module authz_user!
btw: I'm using Debian Etch and the bindings works fine.
# Posted By pinxo | 08/11/06 14:35

Andy Allan's Gravatar Interesting ... I may have to set up a vmware instance and try it out with apache2.2 ... if all goes well, i'll upgrade.
# Posted By Andy Allan | 08/11/06 14:41

Rob Wilkerson's Gravatar See my comment above. The bindings problem (mod_python) is only a problem for Windows installs. They work fine on Linux. I run Apache 2.2.2 on a FC5 box and have never had a problem.
# Posted By Rob Wilkerson | 08/11/06 14:51

Ali Muzaffar Khan's Gravatar You can install SVN on Apache 2.2 its an easy task if anyone needs help contact me. I don't know about trac i am wrestling wih it at the moment ;)
# Posted By Ali Muzaffar Khan | 18/05/07 12:58

Dave Shuck's Gravatar First off, thanks for the Windows instructions. What a pain in the ass it is compared to installing on Linux!

I walked all the way through the instructions without error, but when I went to the browser and hit the page I got an apache error. When looking through the logs, I found this:
__________
[Thu May 24 11:57:10 2007] [error] [client 216.50.229.162] C:/Program Files/Apache Group/Apache2/cgi-bin/trac.cgi is not executable; ensure interpreted scripts have "#!" first line
[Thu May 24 11:57:10 2007] [error] [client 216.50.229.162] (9)Bad file descriptor: don't know how to spawn child process: C:/Program Files/Apache Group/Apache2/cgi-bin/trac.cgi
__________
On the first line of the trac.cgi. I have...
#!C:\Python23\python.exe
... which is the correct path to the python.exe Is there something obvious that I am missing here?
# Posted By Dave Shuck | 24/05/07 18:48

Dave Shuck's Gravatar After some IM chatting with Rob Wilkerson (above), I looked at the possiblity of non-printable characters getting in the way. I opened trac.cgi and did "Save as", choosing ANSI rather than UTF-8. When it overwrote the original file, everything worked.

yay!
# Posted By Dave Shuck | 24/05/07 19:19

Thijs Kruithof's Gravatar Thanks for the info Dave. I had exactly the same problem as you had :) Thnx! It works fine now.
# Posted By Thijs Kruithof | 29/07/07 17:53

Scotch on the Rocks 2008