Trac on Windows XP and IIS
Trac is a web-based software development tool. It's cool features include having a wiki, and integrating beautifully with Subversion for source control. Trac is used by a lot of open source projects, including my favourite map viewer, OpenLayers.
So I wanted to install Trac on my Windows XP based development box. This was all fun until I found that Trac is written in Python. In my experience, programs written in Python ususally don't work well on Windows. Here's how I got it to work:
Step 1: Download and install all components
Follow the instructions on this page to install Python, Trac, ClearSilver, Subversion for Python, and PySqLite.
Step 2: Setup a Trac Project
Follow the instructions on setting up a project as described on this page.
Step 3: Test using tracd
Test your installation using the built-in web server, tracd. If it doesn't work, you've done something wrong.
Step 4: Setup IIS Virtual Directories
Go into your IIS Admin panel and create a new virtual directory. This could be called anything that you want, but I called mine "trac". This virtual directory should map to the "C:\Python24\share\trac\cgi-bin" directory.
Add two application extension mappings for this directory: .cgi and .py files should both execute the "C:\Python24\python.exe -u %s %s" command (the -u and the two %s are very important!).
Step 5: Modify various files
Modify the "C:\Python24\share\trac\cgi-bin\trac.cgi" file to add two lines under the "try:" statement (my test project is installed in the directory c:\projects\trac\testProject\")
try:
import os
os.environ['TRAC_ENV'] = "C:/projects/trac/testProject/"
from trac.web import cgi_frontend
cgi_frontend.run()
Modify the "C:\Python24\Lib\site-packages\trac\web\api.py" file's line 219/220:
Old code:
path_info = property(fget=lambda self: self.environ.get('PATH_INFO', '').decode('utf-8'), doc='Path inside the application')
Replace with:
path_info = property(fget=lambda self: self.environ.get('PATH_INFO','').decode('utf-8').replace( self.environ.get('SCRIPT_NAME', ''), ''), doc='Path inside the application')
Modify the "C:\Python24\Lib\site-packages\trac\web\main.py" file's line 302:
Old code:
path_info = environ.get('PATH_INFO')
Replace with:
path_info = environ.get('PATH_INFO', '').replace( environ.get('SCRIPT_NAME', ''), '').lstrip('/').split('/')
Step 6: Test
Open up your web browser, and go to http://localhost/trac/trac.cgi and see what happens!
Labels: programming
1 Comments:
I might be missing something but you say make a virtual directory in IIS to C:\Python24\share\trac\cgi-bin but I don't see that directory in my trac setup. Thanks
Post a Comment
<< Home