Trac - Setting Up A New Instance

I'm using Trac more and more at work and thought I'd do a few posts (mainly for me to remember things) that I thought would be helpful to others just starting out...

Once you have Trac installed setting up a new 'instance' of Trac is easy. Everything is done using the command line.

If you simply type in trac-admin at the command line you will get back a long list of available commands with some brief help on each one.

CODE:
  1. trac-admin
  2.  
  3. ...
  4.  
  5. initenv
  6.         -- Create and initialize a new environment interactively
  7.  
  8. initenv <projectname> <db> <repostype> <repospath> <templatepath>
  9.         -- Create and initialize a new environment from arguments

To setup a new instance of Trac we'll use the initenv command. Modify your path to meet your system.

CODE:
  1. sudo trac-admin /var/www/trac/projectname initenv

Depending on your environment you may need to change the owner of the newly created Trac directory:

CODE:
  1. sudo chown -R apache:apache projectname

Upon execution you will be asked a series of questions: Trac name, SVN path, etc. For the most part you can accept the defaults for most of these. They can be changed later either through Trac itself or by editing the trac.ini file (located in /var/www/trac/projectname/conf/trac.ini).

Next I usually adjust permissions on the newly setup Trac. To get a list of existing permissions use the permission command:

CODE:
  1. sudo trac-admin /var/www/trac/projectname permission list
  2.  
  3. User              Action
  4. ---------------------------------
  5. anonymous         BROWSER_VIEW
  6. anonymous         CHANGESET_VIEW
  7. anonymous         FILE_VIEW
  8. anonymous         LOG_VIEW
  9. anonymous         MILESTONE_VIEW
  10. anonymous         REPORT_SQL_VIEW
  11. anonymous         REPORT_VIEW
  12. anonymous         ROADMAP_VIEW
  13. anonymous         SEARCH_VIEW
  14. anonymous         TICKET_VIEW
  15. anonymous         TIMELINE_VIEW
  16. anonymous         WIKI_VIEW
  17. anonymous         TICKET_CREATE
  18. anonymous         TICKET_MODIFY
  19. anonymous         WIKI_CREATE
  20. anonymous         WIKI_MODIFY
  21.  
  22. Available actions:
  23.  BROWSER_VIEW, CHANGESET_VIEW, CONFIG_VIEW, FILE_VIEW, LOG_VIEW,
  24.  MILESTONE_ADMIN, MILESTONE_CREATE, MILESTONE_DELETE, MILESTONE_MODIFY,
  25.  MILESTONE_VIEW, REPORT_ADMIN, REPORT_CREATE, REPORT_DELETE, REPORT_MODIFY,
  26.  REPORT_SQL_VIEW, REPORT_VIEW, ROADMAP_ADMIN, ROADMAP_VIEW, SEARCH_VIEW,
  27.  TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, TICKET_MODIFY,
  28.  TICKET_VIEW, TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE,
  29.  WIKI_DELETE, WIKI_MODIFY, WIKI_VIEW

You can see 'anonymous' has access to everything. Depending on your environment you may want to change that. Changing permissions is easy. Below we are removing the ability for anonymous users to create new tickets and instead switching the permissions to authenticated users. I highly recommend the Web Admin plugin which allows you to adjust permissions from within the Trac interface.

CODE:
  1. sudo trac-admin /var/www/trac/projectname permission remove anonymous TICKET_CREATE
  2.  
  3. sudo trac-admin /var/www/trac/projectname permission add authenticated TICKET_CREATE

Usually I set all the create and modify tasks to authenticated.

Next I backup and modify the trac.conf file. Here we are simply telling Apache how to access our new Trac. I'm using Kerberos here at work to authenticate against NT so again your configuration will probably be a bit different.

CODE:
  1. cp /etc/httpd/conf.d/trac.conf trac.conf.date (trac.conf.20070122)
  2.  
  3. vi /etc/httpd/conf.d/trac.conf
  4.  
  5. <Location "/projectname"
  6. SetHandler mod_python
  7. SetEnv PYTHON_EGG_CACHE /var/lib/trac
  8. PythonHandler trac.web.modpython_frontend
  9. PythonOption TracEnv /var/www/trac/projectname
  10. PythonOption TracUriRoot /projectname
  11. </Location> 
  12.  
  13. <Location "/projectname/login"
  14. AuthType Kerberos
  15. KrbMethodNegotiate Off
  16. KrbMethodK5Passwd On
  17. KrbAuthRealms MYDOMAIN.COM
  18. KrbSaveCredentials off
  19. KrbVerifyKDC off
  20. AuthName "nih"
  21. AuthGroupFile /var/www/svn_passwd
  22. Require group repos
  23. </Location>

Now we simply restart Apache and things should work! :)

CODE:
  1. sudo /etc/init.d/httpd restart

10 Comments

  1. Mike Henke
    Posted February 20, 2008 at 1:01 pm | Permalink

    How would you handle one SVN repository with multiple projects folders? I am thinking of creating multiple Trac projects. Then pointing the Trac project to the base project SVN location. But it seems tedious for a developers to check their tickets across all projects.

  2. Posted February 20, 2008 at 1:11 pm | Permalink

    I’m not sure if that’s possible? I need to setup a test environment for Trac so I can play around but just haven’t had any free time lately.

    It might work if you had:

    /svn/project1
    /svn/project2

    And then during the Trac setup pointed each Trac instance to the individual /project1 or /project2 folders.

    For use at work here one of Trac’s biggest weaknesses is the ‘one Trac per project’ scheme. It’s just makes any kind of reporting, etc impossible.

  3. Posted February 20, 2008 at 1:15 pm | Permalink

    Looks like this is somewhat supported:

    http://trac.edgewall.org/ticket/2086 and

    http://trac.edgewall.org/wiki/.....orySupport

  4. Posted February 20, 2008 at 2:32 pm | Permalink

    Looks like the trac site wiki has some info regarding Multi-Project Solution.

    http://trac.edgewall.org/wiki/.....veSolution

    And some other pages regarding Multiple projects (in single db, single trac, multi trac). I’ll have do some reading tonight :-)

  5. Posted February 20, 2008 at 2:35 pm | Permalink

    And there are some other pages regarding Multiple projects (in single db, single trac enviroment, multi trac enviroments). I’ll have do some reading tonight :-)

  6. Posted February 20, 2008 at 3:30 pm | Permalink

    In my environment, I have 1 Svn repository with multiple projects and multiple Trac environments. Each Trac environment points to the Svn project directory containing its source code. Works exactly as you’d expect. In your trac.ini file, you’ll find a directive where you can provide your svn URI. Just point it where you need it to go and you’re off. You may need to resync if you’re changing an existing value.

  7. Posted February 20, 2008 at 5:17 pm | Permalink

    I guess using Mylyn to manage tickets, you wouldn’t have to login to each Trac project instance. Also I found this. http://virtual-planner.palepurple.co.uk/ - collects tickets from multiple repositories/trac instances, to display in one interface for ease of management.

  8. Posted February 20, 2008 at 5:34 pm | Permalink

    I’ve been trying to use Mylyn but just haven’t committed to it 100% - I’m not sure if I like how it integrates so tightly with Eclipse.

  9. Posted February 20, 2008 at 8:27 pm | Permalink

    Interesting (too tightly integrated), I am excited to integrating Mylyn after getting Trac setup. Maybe it won’t be all I thought it would be. I am also considering trying http://tasktop.com/

  10. Posted February 21, 2008 at 8:38 am | Permalink

    Ohhhhhhhh I forgot about Tasktop. I remember seeing that in the past and it looked interesting. I probably just need to get more disciplined and force myself to use Mylyn more.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

Comments for this post will be closed on 20 February 2009.

Creative Commons License

Creative Commons License This article: Trac - Setting Up A New Instance, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License .

Copyright © 2007 thecrumb.com. All rights reserved.