Installing Trac on a virtual server running Ubuntu

At several projects I have used Trac. Trac is an enhanced wiki and issue tracking system for software development projects. But all those times, I didn’t have to install it myself. Until now… I wanted a Trac installation running on Linux that I could take with me to a new project, if necessary. So I entered the world of Virtual Severs, Linux Distributions, Apache HTTP configurations and Trac packages. Since I wasn’t very experienced with any of these subjects, it sure was an instructive experience to me🙂.

Let’s start to look at the virtualisation thing. I wanted to be able to just take a CD with Trac on it with me and install it at any environment I may encounter. The best solution for this is to create a ‘image’ of a virtual server that contains all necessary software. This image can then be installed at any environment that has the possiblity to install the image as a virtual server environment.
I chose for the VMware stack. First of all because it is one of the biggest players in the market, and second, because it is free to use the VMware Player. With this player you can run your created images. To create your VMware images you can use VMware Workstation that is at least free for 30 days. Another option is to download an available virtual image (called ‘appliance’) and to load that with the VMware Player. As you might see here, there are a lot of them already available. Also some with a Trac installation in them. But most of these are rather old, so I decided to create my own installation.

The first thing I did was creating a new virtual machine in VMWare Workstation. I selected Linux Ubuntu as operating system. This will create the virtual machine for you but iwthout the operating system. The Linux software I downloaded from the Ubuntu site. I chose the newest version (Gutsy Gibbon) and selected the Server version, since I don’t need a graphical user interface anyway. After downlaoding this one, I installed it at the virtual machine and conigured the installation of the server as a LAMP installation.

When the OS is installed, it is time to install Trac on it. I followed the instructions from this site to get Trac running on my Linux distribution.
For completeness of this post I will state all necessary steps I took:

  1. To install the Trac software and its dependencies execute the command
  2. sudo apt-get install trac

  3. To install the mod_python module
  4. sudo apt-get install libapache2-mod-python

  5. Create the directory where all the Trac projects will live
  6. sudo mkdir /var/lib/trac
    sudo chown www-data:www-data /var/lib/trac

  7. Edit the Apache config file
  8. sudo vi /etc/apache2/apache2.conf

    and add to it:

     #set up Trac handling
         SetHandler mod_python
         PythonHandler trac.web.modpython_frontend
         PythonOption TracEnvParentDir /var/lib/trac
         PythonOption TracUriRoot /projects

    you can change /projects to be anything you want, as long as you are consistent throughout the other things you do which depend on what you call this location

  9. Create a ‘home’ subversion repository at ‘/var/lib/svn’
  10. (and create a skeleton config for a project) like this:

    sudo mkdir /var/lib/svn
    sudo mkdir /var/lib/svn/MyProject
    sudo svnadmin create /var/lib/svn/MyProject
    sudo svn mkdir file:///var/lib/svn/MyProject/branches file:///var/lib/svn/MyProject/tags
    file:///var/lib/svn/MyProject/trunk -m "Initial structure"

    The files are necessary so that the ‘svn import’ command has something to import (even if it’s empty). If you don’t do all this the ‘initenv’ command will fail, complaining that whatever SVN directory you give it “isn’t an SVN directory”.

  11. Make the necessary directories accesible for Apache
  12. sudo chown -R www-data /var/lib/svn/MyProject
    sudo chown -R www-data /usr/share/trac
    sudo apache2 -k restart

  13. Create a Trac project
  14. sudo trac-admin /var/lib/trac/test_project initenv

    You can accept all defaults for now but make sure you enter for the SVN directory: ‘/var/lib/svn/MyProject’

  15. Change the ownership of ‘/var/lib/trac/test_project’
  16. sudo chown -R www-data:www-data /var/lib/trac/test_project

    Note: the -R is important, as www-data needs to access the database files while sit a couple of directories down from the top project directory.

  17. Restart Apache
  18. sudo apache2 -k restart
    I’m not sure why this is needed but it worked for me.

If everything has gone right, your site will be working now! At least, it did for me🙂

To test the site I had to access it with a browser in my Windows environment. You can do this by entering the IP address of the Linux virtual machine and add ‘/projects/’ to it in the URL, but it looks nicer to add a hostname to the ‘/WINDOWS_HOME/System32/drivers/etc/host/ file and use that hostname, like in my case:
so the URL is then: ‘’.

When you want to use the hostname, make sure that you also provide this hostname as Servername to your VirtualHost in Apache by editing the corresponding config file of your Apache site (in my case ‘/etc/apache2/sites-available/default’). Just set the ServerName to ‘’:

NameVirtualHost *

  ServerAdmin webmaster@localhost

For much more info about Apache’s Virtual Host configurations see the documentation.

About Pascal Alma

Pascal is a senior software developer and architect. Pascal has been designing and building applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Lately he is having great fun by building iOS apps with Swift. Specialties: JEE AWS XML/XSD/XSLT Web Services/SOA Mule ESB/ WSO2 ESB Maven Cloud Technology Swift/ iOS
This entry was posted in Technical. Bookmark the permalink.