What is Trac and why would you want it?
I have already documented in a previous blog how I restored my Trac backup from hosted-projects.com (see http://geekswithblogs.net/twickers/archive/2010/02/02/137766.aspx) but given I also mentioned my use of Trac in a recent presentation at the .NET developers conference, DDD8, (see http://geekswithblogs.net/twickers/archive/2010/01/30/137718.aspx) I thought it only proper to document how to install both SubVersion and Trac from scratch on a new Windows system.
I believe Trac excels as an easy to use, lightweight project management system that is well suited to a small development team (compared to TFS). It benefits from the tight integration of a mature source code management system (SubVersion) with project management. This allows check in comments to directly link to work items, a wiki that can easily refer to work items or source code branches and provides a full web interface for SubVersion.
Trac is an open source issue tracking system, written in Python, with both command line and web interfaces and you can find out more about it here, http://trac.edgewall.org/
The following installation notes were made on Windows 7 Ultimate 64 bit running under VirtualBox 3.1.2. All the software components installed are 32 bit versions (necessary, as not all components have 64 bit setup files readily available).
Documentation available for installation of Trac on Windows
The general installation instructions for Windows can be found at, http://trac.edgewall.org/wiki/TracOnWindows,
More importantly there are incredibly useful step by step instructions at, http://trac.edgewall.org/attachment/wiki/TracOnWindows/Step_by_Step-installation-manual.txt
These instructions provided a great starting basis for the installation, although they do assume some knowledge of SubVersion and Trac, and don’t include details of how to configure initial permissions or run Trac as a Windows service that starts automatically with the operating system.
SubVersion
The most likely server installation for Windows users will be VisualSVN Server (you can download it from here, http://www.visualsvn.com/). I do realise that I may be annoying open source purists by recommending VisualSVN Server, rather than using completely open source components via the svnserve.exe application that I remember configuring back in 2004.
In truth, VisualSVN Server is much easier to install, generates it's own SSL certificate for secure (https) repository access and presents an management utility via an MMC snap-in which is familiar to the average Windows user. The basic version is also FREE. So in these instructions I will use this to provide access to the SubVersion repository.
Installation order
I’m going to take a similar approach to my previous blog on restoring Trac, but if you’ve already read that, do pay attention, as we are adding in installation of VisualSVN Server and the creation and user configuration of the SubVersion repository.
The location of all the components is detailed in my previous blog post (http://geekswithblogs.net/twickers/archive/2010/02/02/137766.aspx) so I decided not to repeat them. The only update is that this used the latest version of python that Trac can use, 2.6.4, with the corresponding 2.6 versions of setup tools and Genshi.
The SubVersion components being installed are all based on SubVersion 1.6.6 as this matches the version contained in VisualSVN Server 2.1. The setup includes all the SubVersion command line tools so if you are familiar with using them to create a repository and/or users feel free to skip the VisualSVN Server Manager steps.
- python-2.6.4.msi (install for all users)
- setuptools-0.6c11.win32-py2.6.exe (Run As Administrator)
- Genshi-0.5.1.win32-py2.6.exe (Run As Administrator)
- (reboot system)
- Add c:\Python26;C:\Python26\Scripts to path. (Windows 7, Control Panel -> System and Security -> System -> Advanced System Settings, Environment Variables button)
- Setup-Subversion-1.6.6.msi (install for all users)
- svn-python-1.6.6.win32-py2.6.exe (Run As Administrator)
- Create the root folders c:\svn (SubVersion) and c:\projects\trac (Trac installations)
- VisualSVN-Server-2.1.msi (subversion 1.6.6, using SubVersion authentication, repositories set to c:\svn)

- Trac-0.11.6.win32.exe (Run As Administrator)
- Start the VisualSVN Server Manager (Start -> All Programs -> VisualSVN folder) and create a new user, ‘liam’ with password ‘4trac’.
- Still in VisualSVN Server Manager, right click on the Repositories root and click Create New Repository with the name NewRepo. Right click on the new repository, click Properties, and select the Security tab. Add the new user ‘liam’ and provide that user with read/write permissions.

- Still in VisualSVN Server Manager, right click on the Repositories root, click Properties, and select the Security tab. Remove Everyone (this should remove Everyone from all child repositories). I prefer not to provide blanket access to all users to my source code respositiories.
- Creating a new Trac installation, beneath the root directory we created earlier, is performed from the command line; trac-admin c:\projects\trac\NewTrac initenv (this starts the setup wizard)
- Project Name set to NewTrac
- Database connection string, hit Enter for default
- Repository type, hit Enter for default of svn
- Path to respository, c:/svn/NewRepo (note the forward slashes!)
- Note: this wizard will create a file called c:\projects\trac\NewTrac\conf\trac.ini and this is where you can edit these settings in the future. This includes setting up your SMTP server settings if you wish to enable e-mail notifications for ticket updates.
- Create the file c:\Python25\Scripts\trace-digest.py as detailed in the step by step guide to support creating a ‘users’ text file to provide authentication with encrypted passwords
- You can then use this script, trace-digest.py, to create users; trac-digest.py -u "liam" -p 4trac >> C:\projects\trac\users.txt.
- This is a manual synchronisation of the user name and password for both SubVersion and Trac, as the user databases are held completely separately. Once that user is created, you use trac-admin at the command line to add that user as a Trac administrator; trac-admin c:\projects\trac\NewTrac permission add liam TRAC_ADMIN
- Finally run the python script to start the Trac web server listening for requests; tracd-script.py -p 80 --auth="*",C:\projects\trac\users.txt,trac c:\projects\trac\NewTrac
- If you are running Windows Firewall a warning dialog will appear, and you will need to Allow Access to Python.exe.
- In an internet browser, browse to http://127.0.0.1/NewTrac, and log in as the user liam with the password 4trac, you should have full access to all functions including the administration options where you can begin to configure security permissions (see below).

Configuring initial security permissions in Trac
The security in Trac is intentionally simple, there is only a single category, subject, to which permissions are assigned. A subject could be a user or a group and there are two special subject categories, created automatically; anonymous and authenticated. These provide the ability to assign permissions for someone who has not formally logged into Trac (to provide anonymous browsing) and also default permissions for any user who has logged in and been authenticated.
In my repositories on hosted-projects.com these special permission categories do not exist. Instead I create user name based permissions, or more usefully group names to which users are added.
You manage the permission via the Admin menu on the far right of the menu bar, which is only visible because we assigned TRAC_ADMIN permissions via the trac-admin command line,

When you select permissions you will see the special subject categories, and if you are like me, and prefer to lock down access, you can tick all the boxes next to anonymous and authenticated, and the click on the Remove Selected Items button to remove them,

To create a group you just add a new subject, i.e. group-allusers and grant a permission such as WIKI_VIEW.

Then create add a new users to this group, i.e. ray.

Although we have provided permissions for a user called ray, that has not created a user with a password in our authentication file, users.txt. We can create ray with a suitable password by running the trace-digest.py script we ran earlier at the command line,
trac-digest.py -u "ray" -p vistaSquad >> C:\projects\trac\users.txt
Once this is configured close down your internet browser, then reopen it and browse again to http://127.0.0.1/NewTrac. You can now login as ray and access should be limited to the Trac Wiki for viewing only. All other menu options should be absent.
Running Trac as a Windows Service
Up to this point we have relied on an open command window running the Trac python scripts in interactive mode. It make much more sense to run Trac as a Windows service so that it starts automatically and does not require a user to login to the system. I found the simple steps on how to do this at a blog entry written by Joshua Thompson http://schmalls.com/blog/2009/10/install-trac-as-a-windows-service.
This uses the Windows 2003 Resource Kit Tools (download it from here). I also checked out the official Microsoft instructions on using these tools, http://support.microsoft.com/kb/137890, but Joshua’s blog is a much easier read and gets the job done just as quickly.
- Install the Windows 2003 Resource Kit Tools, which by default were installed to C:\Program Files (x86)\Windows Resource Kits\Tools
- Open a command window as Administrator user (Windows key, cmd.exe, <Ctrl>+<Shift>+<Enter>)
- Run the following command to install the service and create the relevant root key in the registry; “C:\Program Files (x86)\Windows Resource Kits\Tools\Instsrv.exe” Tracd “C:\Program Files (x86)\Windows Resource Kits\Tools\Srvany.exe”
- As in blog post, edit the registry (run regedit.exe), add a *new* key Parameters, under which you add the following string values;
- Application; c:\Python26\Scripts\tracd.exe
- AppParameters; -p 80 --auth="*",C:\projects\trac\users.txt,trac c:\projects\trac\NewTrac
- AppDirectory; c:\Python26\Scripts
- Once the registry changes are complete, run the Service Control Manager (Start -> Control Panel -> Administrative Tools -> Services, or just run services.msc). There should be a new service, called Tracd, that you can now stop/start and configure just like a standard Windows service. By default it is set to Automatic startup so if you reboot Windows Trac should now be available without logging into the system.
Summary
This is obviously just a bootstrap to get you up and running with SubVersion and Trac as fast as possible so that you can have a play with it. I haven’t dealt with creating an SSL certificate to provide secure https access to Trac, nor have I covered configuring alternate IP addresses and HTTP Ports other than the default (which would be an issue if IIS is already running on the same system).
Final note
Although multi project hosting is also not addressed, it appears this installation method does support multiple Trac installations. Try browsing to http://127.0.0.1 and you should be presented with a list of Trac projects available on the system.