Skip to main content

Creating a Trac instance on Debian Linux

In a post back in October (has it really been that long?) I walked through how to install Trac on Debian Linux. This post will cover the configuration of Trac so that at the end you will have a running Trac system that you can use as a wiki, ticket manager and Subversion repository browser.

First you need to decide where you want your Trac instance to live, I wanted mine to be accessible via a sub-section of a website, but I wanted the instance to live outside of that website's directory structure. I decided on /var/www/Trac which I would link to from within my other website.

To create the instance run the trac-admin command as the root user like so:
trac-admin /var/www/Trac initenv

It will now ask you a number of questions about your environment and project:
* Project Name - enter a human-readable name for your project, this will appear on emails, webpages, etc.
* Database connection string - just hit return to use the default SQLite
* Path to repository - the directory path to your Subversion repository, note: it cannot be a remote repository with the current version of Trac.
* Templates directory - just hit return to use the default templates directory.

If all went well it should report that the environment was created successfully and will give you instructions on how to quickly test that it's working.

Now that we have created the Trac instance, we need to configure Apache to make the site available to the outside world (or intranet if that's more relevant to you). I've set it up to be accessed via a so I added the following stanza to that site's virtual host entry within the /etc/apache2/sites-available directory:
# trac
ScriptAlias /trac "/usr/share/trac/cgi-bin/trac.cgi"
<Location "/trac">
SetEnv TRAC_ENV "/var/www/Trac"

# edit trac.ini to change /trac to /trac-static
Alias /trac-static "/usr/share/trac/htdocs"

<Location "/trac">
AuthType Basic
AuthName "Trac"
AuthUserFile /some/path/htpasswd
Require valid-user

This sets up /trac to point to the Trac master CGI script, and tells the script that the instance lives in /var/www/Trac. The htpasswd file protects the whole site from unauthorised people, (make sure that the htpasswd file exists and has some users in it otherwise you won't be able to access your Trac instance).

Before you restart Apache to see your new Trac instance you need to ensure that the Trac directory structure is owned by the same user as Apache, in my case www-data. Simply run chown -R www-data:www-data /var/www/Trac to sort this out.

Now restart Apache, (/etc/init.d/apache2 reload) and then goto to see Trac in all it's glory.

There are loads of things that you can configure with Trac and general usage instructions are all available within your instance, just click 'Help/Guide' link in the top-right menu bar.

I hope this has been informative, if you have any questions or comments then please don't forget to leave a comment or trackback below!

Technorati Tags: , , , ,


Anonymous said…
I just found your post and it worked great. Thanks a million. (ubuntu dapper)
Anonymous said…

I know little about trac, and was trying to install it to play with it and this helped lots.

One thing I did not understand was that the subversion repository is not used by trac, but is merely shown or presented by trac. You still need an external SVN stack to manage the repository.

Thanks for the article.