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.

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

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

$ sudo 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:

$ cd /var/lib/trac
$ sudo 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.

$ sudo 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.

<location /projects>
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /var/lib/trac
   PythonOption TracUriRoot /projects
</location>
 
<locationmatch "/projects/[^/]+/login">
   AuthType Basic
   AuthName "Trac Authentication"
   AuthUserFile /etc/apache2/dav_svn.passwd
   Require valid-user
</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:

$ sudo 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.

$ sudo 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:

$ cd /usr/share/trac
$ sudo mkdir conf
$ sudo vi conf/trac.ini[/conf]
 
Next enter the following in trac.ini
 
<pre lang="bash">[components]
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.

  • Twitter
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Technorati
  • E-mail this story to a friend!

17 Comments so far

  1. Gabriel on December 13th, 2006

    Sounds very easy to accomplish, I’ve been wanting to install trac to check it out but I didnt have the reference material to do so. Now, I’ll give it a try as soon as I get home.

    About the webadmin plugin…wouldnt it be better to install 0.11 from the beginning? I know it would be more complicated since its not in the repos…but isnt it best practice?

    Does Trac eliminates the need for a bugzilla server?

    If I install trac like you say here, do I need to set up subversion with WebDav like you said on part 1, or can I just skip that part and trac will handle it for me?

    Thanks a lot for these posts! They are great help for svn newbies like me :)

  2. Ariejan on December 13th, 2006

    @Gabriel: I could install 0.11. I thing the steps would pretty much be the same.

    In my opinion, good practice is sticking with the packages your distribution offers you. This will keep you out of trouble when you upgrade your system (or parts of it) later.

    Trac does not need bugzilla. It does need SQLite3 to create a database. But since this is all file based, you don’t need to install anything. It’s just another file in your trac directory.

    Trac does require that you have your Subversion repository on the same filesystem as trac. This means that Trac should be able to access your repository like file:///var/lib/svn/myrep. How you expose your Subversion directory from the outside is up to you.

    You’re welcome. Keep an eye out for my Subverison book :) It’ll be a great reference and learning experience for you!

  3. JackB on January 21st, 2007

    How do I login as the administrator user? When I go to http;//mysite/projects I see the list of repositories I have setup, but everything is read only. There is no ‘admin’ button.

    What am I doing wrong?

  4. Ariejan on January 21st, 2007

    @JackB: You have setup multiple projects, that okay. When you go to a project, there’s a login buttom. You can login. However, you need to give yourself admin permissions first. You need to do this on a per-project basis.

    As you can read in the article: $ sudo trac-admin colt permission add ariejan TRAC_ADMIN

    When you login as ‘ariejan’, the admin button will appear.

  5. JackB on January 21st, 2007

    I followed both of your articles exactly, and the list of projects is shown. When I click on a project however, there is no login button shown, only a blank page. Now, I have only created the ‘trunk’, ‘tag’, and ‘branches’ directories, but shouldn’t these be displayed as well as a login button?

  6. JackB on January 21st, 2007

    Maybe the conf/trac.ini file I created is incorrect. It was difficult to determine what you were doing on this step. Could you show a listing your conf/trac.ini contents?

    My conf/trac.ini file looks like the following:

    [components]
    webadmin.* = enabled

  7. Dan on January 31st, 2007

    I also do not have the admin link, I’ve check to make sure my user has TRAC_ADMIN rights, but I still do not have the button. Any thoughts?

  8. Dan on January 31st, 2007

    Ok, I figured it out. JackB this may help you! Go get the latest stable version of Trac and install it. That’s what the problem was for me, the webadmin that we install required 0.9.3 to work and we installed 0.9. I installed the latest stable which was .10.3 and it works now! HTH.

  9. Neo Tank on May 8th, 2007

    My development server and web server (DMZ) in two diffract network segment. Can I use network file system like NFS or SAMBA with Track and subversion solution here? Otherwise what my options are?

  10. [...] ariejan.net [...]

  11. Alex on June 5th, 2007

    Again, lovely! I also found this : http://natmaster.com/articles/installing_trac_0.10.php very helpful and a little more upto date.

  12. Alex on June 5th, 2007

    Forgot to say – very much looking forward to part 3!!

  13. [...] reference: How to setup Subversion over WebDAV and How to setup Trac, both on [...]

  14. James Brown on January 14th, 2008

    I did just great until the WebAdmin part. That fails when I try to install it. I’m using Ubuntu 7.10 and it includes Trac 0.10.4. Here’s what I get when I install the latest and gratest WebAdmin from the Trac site (says it works with 0.10.4, BTW).

    root@xyzzy:/trac# easy_install /home/james/TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    Processing TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    creating /usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    Extracting TracWebAdmin-0.1.2dev_r6060-py2.4.egg to /usr/lib/python2.5/site-packages
    Adding TracWebAdmin 0.1.2dev-r6060 to easy-install.pth file

    Installed /usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    Processing dependencies for TracWebAdmin==0.1.2dev-r6060
    Searching for TracWebAdmin==0.1.2dev-r6060
    Reading http://cheeseshop.python.org/pypi/TracWebAdmin/
    Couldn’t find index page for ‘TracWebAdmin’ (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading http://cheeseshop.python.org/pypi/
    No local packages or download links found for TracWebAdmin==0.1.2dev-r6060
    error: Could not find suitable distribution for Requirement.parse(’TracWebAdmin==0.1.2dev-r6060′)

    ***************************************************************************

    If I use the previous version (using your link from the article) I get the following …

    root@xyzzy:/trac# easy_install /home/james/TracWebAdmin-0.1.2dev_r4240-py2.4.egg
    Processing TracWebAdmin-0.1.2dev_r4240-py2.4.egg
    creating /usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r4240-py2.4.egg
    Extracting TracWebAdmin-0.1.2dev_r4240-py2.4.egg to /usr/lib/python2.5/site-packages
    Removing TracWebAdmin 0.1.2dev-r6060 from easy-install.pth file
    Adding TracWebAdmin 0.1.2dev-r4240 to easy-install.pth file

    Installed /usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r4240-py2.4.egg
    Processing dependencies for TracWebAdmin==0.1.2dev-r4240
    Searching for TracWebAdmin==0.1.2dev-r4240
    Reading http://cheeseshop.python.org/pypi/TracWebAdmin/
    Couldn’t find index page for ‘TracWebAdmin’ (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading http://cheeseshop.python.org/pypi/
    No local packages or download links found for TracWebAdmin==0.1.2dev-r4240
    error: Could not find suitable distribution for Requirement.parse(’TracWebAdmin==0.1.2dev-r4240′)

    **********************************************************************

    So, no matter which way I do this, it can’t find a suitable distribution for TracWebAdmin. I’m sure this must be something obvious, but I just can’t see it.

    Thanks,

    - James

  15. Jason on January 21st, 2008

    This is a really fantastic tutorial, thanks so much! -Jason

  16. Irimia Suleapa on June 8th, 2008

    @James Brown
    Try to rename the file simple TracWebAdmin.egg.

    Take a look here …

    irinel@Trinity:~$ mv TracWebAdmin-0.1.2dev_r6060-py2.4.egg.zip TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    irinel@Trinity:~$ sudo easy_install TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    Processing TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    creating /usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    Extracting TracWebAdmin-0.1.2dev_r6060-py2.4.egg to /usr/lib/python2.5/site-packages
    Adding TracWebAdmin 0.1.2dev-r6060 to easy-install.pth file

    Installed /usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r6060-py2.4.egg
    Processing dependencies for TracWebAdmin==0.1.2dev-r6060
    Searching for TracWebAdmin==0.1.2dev-r6060
    Reading http://cheeseshop.python.org/pypi/TracWebAdmin/
    Couldn’t find index page for ‘TracWebAdmin’ (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading http://cheeseshop.python.org/pypi/
    No local packages or download links found for TracWebAdmin==0.1.2dev-r6060
    error: Could not find suitable distribution for Requirement.parse(’TracWebAdmin==0.1.2dev-r6060′)

    … and here …

    irinel@Trinity:~$ sudo easy_install TracWebAdmin.egg
    Processing TracWebAdmin.egg
    creating /usr/lib/python2.5/site-packages/TracWebAdmin.egg
    Extracting TracWebAdmin.egg to /usr/lib/python2.5/site-packages
    Removing TracWebAdmin 0.1.2dev-r6060 from easy-install.pth file
    Adding TracWebAdmin 0.1.2dev to easy-install.pth file

    Installed /usr/lib/python2.5/site-packages/TracWebAdmin.egg
    Processing dependencies for TracWebAdmin==0.1.2dev
    Finished processing dependencies for TracWebAdmin==0.1.2dev
    irinel@Trinity:~$

    Btw, nice tutorial :).

  17. [...] How to setup a Ubuntu development server – Part 2 [...]

Leave a Reply