Multiple project Trac set-up

I’ve already installed Trac and I now want to be able to set-up multiple projects with the minimum of fuss.

My requirements are:

  • Not having to mess with the Apache configuration every time I add a new project because I don’t want to have to restart apache
  • Make some simple modifications to the stanadard trac.ini so that, for example, the logo at the top links to the home of that trac project
  • Improve upon the default authentication where logging out involves closing the browser (which is a drag when accessing multiple projects)
  • Change the default wiki page text

The most important job is to get Apache set-up properly. I’m using mod_python so:
apt-get install libapache2-mod-python

I then set-up a VirtualHost for http://my.trac.url, thus:

<code><VirtualHost *>

DocumentRoot /var/www/my.trac.docroot

ServerName my.trac.url

ServerAdmin webmaster@my.trac.url

LogFormat "%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i""

TransferLog /var/log/apache2/trac-access.log

ErrorLog /var/log/apache2/trac-error.log</code>
<LocationMatch "/.+/">
 SetHandler mod_python
 PythonInterpreter main_interpreter
 PythonHandler trac.web.modpython_frontend
 PythonPath "sys.path + ['/export/trac']"
 PythonOption TracEnvParentDir /export/trac
 PythonOption TracUriRoot /
 </LocationMatch>

</VirtualHost>Code language: PHP (php)

Note the LocationMatch. From the docs:

This will instruct Apache to use mod_python for all locations different from root while having the possibility of placing a custom home page for root in your DocumentRoot folder.

Therefore in /var/www/my.trac.docroot I’ve placed a one line PHP script that redirects users to our main website url.

After restarting Apache I then set-up a new project ‘project1’ as per my mini Trac install how-to and visiting http://my.trac.url/project1/ gives me the vanilla Trac interface so we know it’s all working.

The rest of the configuration is with Trac itself and is down to personal requirements and mine are already listed above. I’ve scripted everything I need to do to get a new project up and running and don’t intend to go though it all here. You can however download it and use it for your own purposes. You use this at your own risk and you should bear in mind the following cavets:

  • Assumes that the Account Manager plugin is already installed. I did easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
  • The first user input is used as the Trac project name AND should match the name of the already set-up svn project
  • I’m using MySQL on the backend
  • A few of the trac.ini settings at the end are hard-coded though it is easy to change them

I’m a lot more impressed with this version of Trac than the much older version we were using before, and with the above setup, I can now have a project up and running within a few minutes.
Related
http://trac.edgewall.org/wiki/TracModPython
http://trac-hacks.org/wiki/AccountManagerPlugin


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *