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.

trac-admin

...

initenv
        -- Create and initialize a new environment interactively

initenv
        -- 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.

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:

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:

sudo trac-admin /var/www/trac/projectname permission list

User              Action
---------------------------------
anonymous         BROWSER_VIEW
anonymous         CHANGESET_VIEW
anonymous         FILE_VIEW
anonymous         LOG_VIEW
anonymous         MILESTONE_VIEW
anonymous         REPORT_SQL_VIEW
anonymous         REPORT_VIEW
anonymous         ROADMAP_VIEW
anonymous         SEARCH_VIEW
anonymous         TICKET_VIEW
anonymous         TIMELINE_VIEW
anonymous         WIKI_VIEW
anonymous         TICKET_CREATE
anonymous         TICKET_MODIFY
anonymous         WIKI_CREATE
anonymous         WIKI_MODIFY

Available actions:
 BROWSER_VIEW, CHANGESET_VIEW, CONFIG_VIEW, FILE_VIEW, LOG_VIEW,
 MILESTONE_ADMIN, MILESTONE_CREATE, MILESTONE_DELETE, MILESTONE_MODIFY,
 MILESTONE_VIEW, REPORT_ADMIN, REPORT_CREATE, REPORT_DELETE, REPORT_MODIFY,
 REPORT_SQL_VIEW, REPORT_VIEW, ROADMAP_ADMIN, ROADMAP_VIEW, SEARCH_VIEW,
 TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, TICKET_MODIFY,
 TICKET_VIEW, TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE,
 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.

sudo trac-admin /var/www/trac/projectname permission remove anonymous TICKET_CREATE

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.

cp /etc/httpd/conf.d/trac.conf trac.conf.date (trac.conf.20070122)

vi /etc/httpd/conf.d/trac.conf

SetHandler mod_python
SetEnv PYTHON_EGG_CACHE /var/lib/trac
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /var/www/trac/projectname
PythonOption TracUriRoot /projectname

AuthType Kerberos
KrbMethodNegotiate Off
KrbMethodK5Passwd On
KrbAuthRealms MYDOMAIN.COM
KrbSaveCredentials off
KrbVerifyKDC off
AuthName "nih"
AuthGroupFile /var/www/svn_passwd
Require group repos

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

sudo /etc/init.d/httpd restart
Recent Related Posts

10 thoughts on “Trac – Setting Up A New Instance

  1. 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. 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. 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.

  4. 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.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>