Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

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.

  1. python-2.6.4.msi (install for all users)
  2. setuptools-0.6c11.win32-py2.6.exe (Run As Administrator)
  3. Genshi-0.5.1.win32-py2.6.exe (Run As Administrator)
  4. (reboot system)
  5. Add c:\Python26;C:\Python26\Scripts to path. (Windows 7, Control Panel -> System and Security -> System -> Advanced System Settings, Environment Variables button)
  6. Setup-Subversion-1.6.6.msi (install for all users)
  7. svn-python-1.6.6.win32-py2.6.exe (Run As Administrator)
  8. Create the root folders c:\svn (SubVersion) and c:\projects\trac (Trac installations)
  9. VisualSVN-Server-2.1.msi (subversion 1.6.6, using SubVersion authentication, repositories set to c:\svn) Visual SVN installation options
  10. Trac-0.11.6.win32.exe (Run As Administrator)
  11. Start the VisualSVN Server Manager (Start -> All Programs -> VisualSVN folder) and create a new user, ‘liam’ with password ‘4trac’.
  12. 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.Adding the new user
  13. 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.
  14. 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)
    1. Project Name set to NewTrac
    2. Database connection string, hit Enter for default
    3. Repository type, hit Enter for default of svn
    4. Path to respository, c:/svn/NewRepo (note the forward slashes!)
    5. 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.
  15. 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
  16. You can then use this script, trace-digest.py, to create users; trac-digest.py -u "liam" -p 4trac >> C:\projects\trac\users.txt.
  17. 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
  18. 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
  19. If you are running Windows Firewall a warning dialog will appear, and you will need to Allow Access to Python.exe.
  20. 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).

Logging into trac

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,
Accessing the Trac Admin pages

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,

Trac permissions

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

Trac Admin - adding an all users group

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

Trac Admin - adding a new user to a group

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.

  1. Install the Windows 2003 Resource Kit Tools, which by default were installed to C:\Program Files (x86)\Windows Resource Kits\Tools
  2. Open a command window as Administrator user (Windows key, cmd.exe, <Ctrl>+<Shift>+<Enter>)
  3. 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”
  4. As in blog post, edit the registry (run regedit.exe), add a *new* key Parameters, under which you add the following string values;
    1. Application; c:\Python26\Scripts\tracd.exe
    2. AppParameters; -p 80 --auth="*",C:\projects\trac\users.txt,trac c:\projects\trac\NewTrac
    3. AppDirectory; c:\Python26\Scripts
  5. 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.

 

Print | posted on Monday, February 8, 2010 1:46 AM

Comments on this post

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
There is a addon for visualsvn from the same team to integrate trac into visualsvn without installing so much packages:
http://www.visualsvn.com/server/trac/

Have Fun.
Left by Claus on Mar 07, 2010 9:26 PM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
@Claus didn't know about the VisualSVN plugin, although that might be because it isn't promoted heavily on the VisualSVN site.

They do have the following warning, which might scare some people off a bit;

Currently we do not technically support Trac plug-in for VisualSVN Server. Please note that Trac plugin for VisualSVN Server was never released officially and you can use it on your own risk. We do not plan to update the plug-in on a regular basis.
Left by Liam Westley on Mar 07, 2010 9:41 PM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
Hi, yes I know this warning, but it works perfectly. VisualSVN has left a comment somewhere in their FAQ about this plugin, that they will be updating it in the next couple of weeks, to integrate it more into visualsvn. (It seems the User keep demanding this ;-)
But even if they dont update it. Everything is stored in one "trac" directory, which can be easily updated through the trac/geshi installer and so on. I dont want to favor it, its just easier and integrated into the apache which visualsvn brings with. :)
Left by Claus on Mar 08, 2010 12:00 AM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
@Claus Thanks for the extra information, that sounds pretty good news for Windows users who want to use Trac (which I think they should). Although it's nice to know how everything *should* go together, it's a real barrier compared to one click installations.

I might give it a try and see if it can 'restore' an Apache setup as well as handle a new build.
Left by Liam Westley on Mar 08, 2010 12:07 AM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
Hi there,

thank you very much for your great description. This step by step "how to" is the very best! Super detailed! All the best to you. Keep up your great work.
Left by Thomas Mallohn on Mar 08, 2010 4:02 AM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
Thanks for a GREAT step by step! I've struggled with tons of issues for the past week or two trying to add a Trac front end to our existing VisualSVN repositories. This document saved my sanity!
Left by R.G. on Mar 10, 2010 9:02 AM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
i have installed Trac yesterday.. then i shutdown the system.. today i start the system i browsed the IE. its show problem loading page,,

could anyone tell me how to start the service for windows,,
Left by abdul on Mar 24, 2010 5:07 PM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
Can you please tell me how to setup brand new git with trac
Left by Royal Pinto on Sep 06, 2011 11:54 PM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
@Royal Pinto

I'm afraid I haven't got my head round Git yet so can't help, although theoretically it should be possible as there are Git plug ins for Trac.
Left by Liam Westley on Sep 07, 2011 12:19 AM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
Hello, my name is Maximillian and I'm from Argentina, this was an excellent contribution and I have been very helpful, thank you. I ask you two questions, 1 - How I can translate into Spanish Trac?, 2 - As I can do to authenticate users with Active Directory?. Thank you very much for your time. A friendly greeting.
Left by Maximillian Tomietto on Sep 23, 2011 1:14 AM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
point "15. 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"
I can't do this ! How can I create that file? where is the step by step guide?
Left by ciro on Oct 13, 2011 9:01 PM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
@ciro

The step by step instructions I was referring to are at this location,

http://trac.edgewall.org/attachment/wiki/TracOnWindows/Step_by_Step-installation-manual.txt

I just checked to see that it is still available, and it is, and I've copied the bit from the step by step installation guide that deals with creating the encrypted passwords below.

Thanks,

Liam

----------------------------------------------

60 11 -For authentication create trace-digest.py file
61
62 save the python code (between the -- lines) into c:\Python25\Scripts\trace-digest.py
63 ---------------------------------------------------------
64 from optparse import OptionParser
65 import md5
66
67 # build the options
68 usage = "usage: %prog [options]"
69 parser = OptionParser(usage=usage)
70 parser.add_option("-u", "--username",action="store", dest="username", type = "string",
71 help="the username for whom to generate a password")
72 parser.add_option("-p", "--password",action="store", dest="password", type = "string",
73 help="the password to use")
74 (options, args) = parser.parse_args()
75
76 # check options
77 if (options.username is None) or (options.password is None):
78 parser.error("You must supply both the username and password")
79
80 # Generate the string to enter into the htdigest file
81 realm = 'trac'
82 kd = lambda x: md5.md5(':'.join(x)).hexdigest()
83 print ':'.join((options.username, realm, kd([options.username, realm, options.password])))
84 ---------------------------------------------------------
85
86 12- create userauth file if using httpd webserver and --auth parameter (OBS not for -basic--auth)
87
88 >trac-digest.py -u "admin" -p adminpassword >> C:\projects\users.txt
Left by Liam Westley on Oct 14, 2011 10:49 PM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
Hi
I installed the trac by following the steps as mentioned. i am getting the error saying can't synchronize with repository "(default)" (unsupported version control system(svn) :Can't find appropriate component,maybe the plugin not enabled

Can you please let me know the issue. i used Trac1.0 instead of Trac 0.11.6
Left by MaheshKumar on Nov 25, 2012 6:12 PM

# re: Step by Step: Trac on Windows, how to install a brand new SubVersion and Trac installation onto a Windows System

Requesting Gravatar...
Thank you very much for your great post. It is very useful for me.
I only met one problem with the script on the file trac-digest.py when I run the command-line. The problem is that "DeprecationWarning: the md5 module is deprecated; use hashlib instad import md5". To fix this problem, I only change 2 things in your script:
------------------
1. import md5 --> import hashlib
2. kd = lambda x: md5.md5(':'.join(x)).hexdigest() --> kd = lambda x: hashlib.md5(':'.join(x)).hexdigest()
------------------

I would like to share with you here.
Left by VU HUY THAO on Aug 27, 2013 8:21 PM

Your comment:

 (will show your gravatar)