| 17 February 2008 |
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:
- To install the Trac software and its dependencies execute the command
- To install the mod_python module
- Create the directory where all the Trac projects will live
- Edit the Apache config file
-
<location /projects> #set up Trac handling
-
SetHandler mod_python
-
PythonHandler trac.web.modpython_frontend
-
PythonOption TracEnvParentDir /var/lib/trac
-
PythonOption TracUriRoot /projects
-
</location>
- Create a 'home' subversion repository at '/var/lib/svn'
- Make the necessary directories accesible for Apache
- Create a Trac project
- Change the ownership of '/var/lib/trac/test_project'
- Restart Apache
sudo apt-get install trac
sudo apt-get install libapache2-mod-python
sudo mkdir /var/lib/trac
sudo chown www-data:www-data /var/lib/trac
sudo vi /etc/apache2/apache2.conf
and add to it:
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
(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".
sudo chown -R www-data /var/lib/svn/MyProject
sudo chown -R www-data /usr/share/trac
sudo apache2 -k restart
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'
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.
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:
192.168.1.11 my.tracserver.com
so the URL is then: 'http://my.tracserver.com/projects/'.
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 'my.tracserver.com':
-
NameVirtualHost *
-
<virtualHost *>
-
ServerAdmin webmaster@localhost
-
ServerName my.tracserver.com
-
...
-
</virtualHost>
For much more info about Apache's Virtual Host configurations see the documentation.


1 comment to 'Installing Trac on a virtual server running Ubuntu'
7 February 2009
[...] Setup Trac Trac’s home page This is a good guide that works for me, please click here Possibly related posts: (automatically generated)Setting up fetchmail in Ubuntu 8.0.4Understanding [...]