Last updated

How to setup a Ubuntu development server - Part 2

Also read Part 1 - Subversion.

In this part I will tell you how to install Trac on top of your Subversion repositories on your Ubuntu development server. Trac offers you a wiki, roadmap, tickets (tracking system) and access to your SubVersion repository. All of this is bundeled in a very sexy web interface.

Well, let’s get to work now and get Trac installed. When you’re done you will have trac available for all your Subversion repositories.

Install Trac

First thing to do is install trac. Here I will also install mod_python for your apache webserver and python-setuptools that we’ll need later with the webadmin plugin.

1sudo apt-get install trac libapache2-mod-python python-setuptools

Now, I create a directory where all Trac information will be stored.

1sudo mkdir -p /var/lib/trac

Common sense dictates that you use the same name here for the trac environment as for the subversion repository.

Change to the trac directory and intitialize the project:

1cd /var/lib/trac
2sudo trac-admin colt initenv

You’ll need to name the project, choose a database file (default is okay), specify where the subversion repository resides ( /var/lib/svn/colt, in this case) and a template (the default is okay here too).

I recommend you also create an administrator user right now. Make sure you add a user who’s already in your /etc/apache2/dav_svn.passwd file.

1sudo trac-admin colt permission add ariejan TRAC_ADMIN

Well, that’s it. Trac has been installed. Now let’s make sure we can access trac through the web.

Configuring Apache

Configuring apache is rather easy when you know what to do. Add the following code to /etc/apache2/sites-available/default (at the bottom before the end of the virtualhost tag) or put it in a seperate virtual host file if you want to dedicate a special domain to this.

 1<location /projects>
 2    SetHandler mod_python
 3    PythonHandler trac.web.modpython_frontend
 4    PythonOption TracEnvParentDir /var/lib/trac
 5    PythonOption TracUriRoot /projects
 6</location>
 7
 8<locationmatch "/projects/[^/]+/login">
 9    AuthType Basic
10    AuthName "Trac Authentication"
11    AuthUserFile /etc/apache2/dav_svn.passwd
12    Require valid-user
13</locationmatch>

Notice here, again that we use TracEnvParentDir to show we host multiple instances of Trac. You may change the TracUriRoot to something different.

Again, make sure to chown your Trac installation to www-data:

1sudo chown -R www-data.www-data /var/lib/trac

Now, access your trac over the web: http://example.com/projects for a complete listing of hosted projects or http://example.com/projects/colt for the COLT project.

You may also login now! As you can see, we use the dav_svn.passwd file here so everyone with subversion access also has access to trac.

Webadmin

Normally you would administrate a Trac installation through the command-line interface we used to initialize the environment and add the administrator user. Nowadays there is a webadmin plugin for Trac, which will be included in Trac from version 0.11. Since Ubuntu ships with Trac 0.9.3 we need to add this webadmin ourselves.

First, download the following file to your server: http://trac.edgewall.org/attachment/wiki/WebAdmin/TracWebAdmin-0.1.2dev_r4240-py2.4.egg.zip.

Don’t unzip this file, just remove the .zip extension.

Because we installed setuptools earlier, we can now use easy_install to install this plugin system-wide, enabling it for all our trac installations.

1sudo easy_install TracWebAdmin-0.1.2dev_r4240-py2.4.egg

Next we enable webadmin in the global configuration file of track. You may need to create the ‘conf’ directory in this case:

1cd /usr/share/trac
2sudo mkdir conf
3sudo vi conf/trac.ini[/conf]

Next enter the following in trac.ini

1[components]
2    webadmin.* = enabled

Save the file and off you go. Login as the administrator user you specified earlier and you can make use of the ‘admin’ button that has appeared in the menu of Trac.

Enjoy your trac! Next time (in Part 3) I will talk about setting up a commit-hook so Trac tickets are updated by posting subversion commit messages (throught commit-hooks).

Also read Part 1 - Subversion on how to install Subversion over WebDAV.