Trac setup

Posted by Graham Stratton Thu, 15 Feb 2007 17:39:06 GMT

Just in case I haven’t already expressed my opinion on this: trac is wonderful. It’s a simple integration of subversion with an issue tracker and a wiki. It’s probably not that difficult to set up by default, but for some reason I chose to use Postgres instead of SQLite, so there’s a little bit to it. I covered installing everything elsewhere, so here I’m just going to describe setting up the database and configuring it all.

First we need to create a subversion repository. This needs to be writable by the user which Apache is running as, probably www-data or similar.

sudo svnadmin create /var/svn/hippocms
sudo chown -R www-data /var/svn/hippocms/

Now we need to configure Apache:

  <Location /svn>
    DAV svn
    SVNParentPath /var/svn
    AuthType Basic
    AuthName "Subversion" 
    AuthUserFile /etc/svn-auth
    Require valid-user
  </Location>

The SVNParentPath variable makes all the subdirectories of this directory which should be repositories available, but denies access to the directory itself.

We’re only protecting the repository with BasicAuth here; you’ll need to use https to make this secure. We need to create the htpasswd file:

sudo htpasswd -c /etc/svn-auth graham

So now, you should be able to access the repository through the web at http://your.server/svn/hippocms/

And you should be able to check out its emptyness with
svn co http://cambridgewebdevelopment.co.uk/svn/hippocms/

Next we set up the Apache to host trac:

  Alias /trac "/usr/share/trac/htdocs" 

  ScriptAlias /hippocms /usr/share/trac/cgi-bin/trac.cgi
  <Location "/hippocms">
    SetEnv TRAC_ENV "/var/trac/hippocms" 
    AuthType Basic
    AuthName "hippocms" 
    AuthUserFile /var/trac/hippocms/.htpasswd
    Require valid-user
  </Location>
And we need to add a user for Apache to authenticate:
sudo htpasswd -c /var/trac/hippocms/.htpasswd graham

Finally we need to create a database and create a trac user:

sudo su - postgres -c createdb hippocms
sudo su - postgres -c psql hippocms
# create user trac with password 'secret';

Now we’re ready to initialise our trac environment:

sudo trac-admin /var/trac/hippocms initenv

And everything should Just Work.

Posted in  | 2 comments

Comments

  1. Sean Tierney said 194 days later:

    Graham, thanks for the tutorial. For a truly “it just works” setup experience check out the JumpBox for Trac/SVN-> http://www.jumpbox.com/jumpbox-for-tracsubversion-software-project-management

    1min install and fully portable.

    sean

  2. Anime News said 400 days later:

    I’ve been using it with SQLite… But with this handy tutorial maybe it’s time to move to postgres :)

    Thanks mate.

(leave url/email »)

   Comment Markup Help Preview comment