Monday 01 May 2006

Setting Up Subversion And Trac

PLEASE NOTE: THIS ENTRY IS OUT OF DATE!

Trac is now at 0.11.4 and some of the packages have been updated or are no longer necessary.

Please refer to the TracInstallPlatforms instructions to install the latest versions of SVN & Trac.

I have previously mentioned Subversion and Trac in an entry I made in July last year. I am still using it for version control for QuackScript, but I recently installed it at work to help me out with my “webmastery” – it’s very easy to lose track of what files you’ve updated when, when you’re in charge of 6 company sites, plus a few for clients.

I decided to write up the instructions on how I set up the software packages required if anyone else wants to give it a go, and finds the existing instructions a little confusing in places.

A step by step guide to installing Subversion and Trac on Windows.

These instructions borrow heavily from TracOnWindows, but I have updated them to use a few of the newer versions of the software packages that I know work together, and to simplify the steps needed to get Trac running.

This guide assumes that you are pretty computer savvy, and know roughly what you’re doing.

There are two main steps, 1) installing Subversion and 2) installing Trac.

The files you will require for both steps are as follows:

    For Subversion

  1. Apache 2.0.59
  2. Subversion 1.4.3 (svn-1.4.3-setup.exe)
  3. For Trac

  4. Python 2.4.4
  5. Python 2.4 Bindings (svn-win32-1.4.3_py24.zip)
  6. Docutils 0.4
  7. PySQLite 2.3.3
  8. Clearsilver 0.9.14
  9. Trac 0.10.4
  10. Diffutils 2.8.7-1

The instructions continue below.

Download all of the above files and put them in a folder together.

Installing Subversion Prerequisites

1. Install Apache (If you are running IIS, shut it down before installing Apache, and change its status to ‘Manual’ or ‘Disable’).

2. Install Subversion.

3. Make sure that C:\Program Files\Subversion\bin has been added to the Path in Environment Variables, the installer should do this for you.

Creating Your Repository

4. Create the main directory to hold your repository:

C:\> md c:\svn

5. Using svnadmin create the repository in Subversion:

C:\> svnadmin create c:\svn\repo1

6. Create a skeleton repository structure in c:\temp\project, here’s an example:

/project

/projectname

/branches

/trunk

files

7. Build the repository tree by importing your skeleton structure:

C:\> svn import c:\temp\project file:///c:/svn/repo1 -m "Initial Load"

Configuring Apache

8. Create a password file to lock down access to your repository:

C:\> "C:\Program Files\Apache Group\Apache2\bin\htpasswd" -cm c:\svn\.htaccess admin

9. Open httpd.conf from C:\Program Files\Apache Group\Apache2\conf.

10. Uncomment the following lines:

LoadModule dav_module modules/mod_dav.so

LoadModule dav_fs_module modules/mod_dav_fs.so

11. Check the Subversion installer has added the following lines, if it hasn’t add them yourself:

LoadModule dav_svn_module "C:/Program Files/Subversion/bin/mod_dav_svn.so"

LoadModule authz_svn_module "C:/Program Files/Subversion/bin/mod_authz_svn.so"

12. You need to add a location root so you can access the repository, so paste the following to the bottom of the config file:

# Subversion

<Location /svn>

DAV svn

SVNParentPath c:/svn

AuthType Basic

AuthName "Subversion Repository"

AuthUserFile c:/svn/.htaccess

Require valid-user

</Location>

13. Uncomment the following line so Apache handles CGI scripts:

AddHandler cgi-script .cgi

14. Restart Apache using the Service Monitor.

15. Open your web browser and test that you can connect to your Subversion repository.

http://[hostname]/svn/repo1

Installing Trac Prerequisites

16. Install Python 2.4.4 to C:\Python24.

17. Add C:\Python24 to your Path variable.

18. Extract the Python Bindings zip file and move the libsvn and svn directories to C:\Python24\Lib\site-packages. (Make sure that the version of the bindings you download match the version of Subversion you are using.)

19. Expand docutils.tar.gz to C:\docutils-0.4 and install:

C:\docutils-0.4> python setup.py install

20. Install PySQLite.

21. Install ClearSilver.

22. Install Trac.

23. Install Diffutils and add C:\Program Files\GnuWin32\bin to your Path.

Configuring Trac

24. Copy trac.cgi from C:\Python24\share\trac\cgi-bin to C:\Program Files\Apache Group\Apache2\cgi-bin.

25. Use a text editor such as notepad to open trac.cgi and ensure the first line contains the correct path for your Python installation (C:\Python24\python.exe).

25. Run trac-admin to start configuring your Trac database.

C:\Python24\scripts> python trac-admin c:/svn/trac.db

26. Initialize the Trac database.

Trac [c:/svn/trac.db]> initenv
  Enter project name

Project

Enter path to repository

C:\svn\repo1

Enter path to templates

C:\Python24\share\trac\templates

27. Add administrative permissions (the below adds all permissions for ‘admin’ user)

Trac [c:/svn/trac.db]> permission add admin TRAC_ADMIN

Add Trac To Apache

28. Open httpd.conf from C:\Program Files\Apache Group\Apache2\conf.

29. Add the following under the section you added for Subversion.

# Trac

# Link the static files into /trac-static/

# You'll need to change trac.ini to point to /trac-static/ instead of /trac/

# trac.ini is in the trac.db\conf folder

Alias /trac-static "C:/Python24/share/trac/htdocs"

# Map the Trac CGI into /trac/

ScriptAliasMatch ^/trac(.*) "C:/Program Files/Apache Group/Apache2/cgi-bin/trac.cgi$1"

# Tell Trac where its environment is stored

<Location "/trac">

SetEnv TRAC_ENV "c:/svn/trac.db"

</Location>

# Authenticate the user

<Location "/trac/login">

AuthType Basic

AuthName "Project"

AuthUserFile c:/svn/.htaccess

Require valid-user

</Location>

# Allow access to the Trac static files

<Directory "C:/Python24/share/trac/htdocs">

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

30. Open trac.ini from C:\svn\trac.db\conf:

31. Change the htdocs_location to the following:

htdocs_location = /trac-static/

32. Reboot your computer, this is pretty important since Trac may not work properly unless you do.

33. Finally, test you can connect to Trac through your web browser.

http://[hostname]/trac/

Congratulations, you now have a working Subversion repository with Trac for version control and project management.

P.S. For a source control client, I use TortoiseSVN which integrates into Explorer, so it is very easy to see files you have updated and need to be committed to your database. There are other SVN clients out there, but I find Tortoise to be the best.

 

Comments

  1. I'd like to know how you made subversion 1.3.1 working with Apache 2.2.0. Because the subversion modules are explicitly declared as not compatible to Apache 2.2.0

  2. Crap, thank you for noticing that error. I didn’t mean 2.2 at all, I meant to put 2.0.58. I have corrected my post now.

    Sorry for the confusion!

    If you use 2.0.58 then there shouldn’t be any problems setting Subversion up.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

quack - © 2002-2012
Monthly Archives
Category Archives