Trac on Windows Installation & Upgrade Guide
Note: This is about Trac 0.9
What follows are specific instructions for installing, setting up, and upgrading Trac on Windows.
Choose between these options of installing Trac:
- Trac running without Apache or IIS using tracd and svnserve is the simplest setup. It is stripped for all optional dependencies. It might be taken as a first step to get things running. You should then be able to pick the missing steps from the Apache CGI based setup found on this page as a second step.
- The 'traditional' Apache CGI based setup is described just below.
- Also, after installing the CGI-based setup, you may want to switch to using mod_python which speeds up Trac's response times considerably.
If you are trying to upgrade to Trac 0.9, see the instructions at the end of this file.
Installation of Subversion and Trac served via Apache CGI
Versions used in this example (Feb 2006):
- Trac 0.9.x
- Clearsilver 0.9.14 binaries
- Python 2.3.5
- Apache 2.0.54 or 2.0.55
- Subversion 1.2.x
- Python 2.3 Bindings for subversion 1.2.x
- SQLite 3.2.2 (optional)
- eGenix.com mx Extensions for Python (only required if using PostgreSQL)
- docutils 0.3.9 (optional)
Please update this Wiki page if you find it is different from your experience. If you have any problems, I would also suggest posting the solutions here for the common good. Please reference the version number you are having difficulties with, but assume that readers will be using the latest version (and issues from previous versions can disappear into wiki history) Contributors: please add your name to the list at the end - Thanks in advance!
For Subversion issues on Windows see the TortoiseSVN site, particularly the server section.
Trac running on Microsoft's Internet Information Server (IIS) is highly experimental. See #697.
- Get & Read Version Control with Subversion
Install Subversion Pre-Requisites
- Install version 2.0 of Apache (If you are running IIS, shut it down before installing Apache, and change its status to 'Manual' or 'Disable'). This must be version 2.0 of the apache server and not version 2.2 or the apache modules shipped with the latest subversion (1.3.2 at the time of writing) will not work!
Add C:\svn\bin to the path
Note: Be sure to have the MSVCP60.DLL in your PATH, otherwise Apache will refuse to start with the SVN module.
- Create repository directory
C:\> md c:\svn
- Create repository
C:\> svnadmin create c:\svn\repo1
- Create skeleton repository structure in c:\temp\project
/project /vendor /tags /trunk files /projectname /branches /tags /trunk files
- Build repository tree
C:\> svn import c:\temp\project file:///c:/svn/repo1 -m "Initial Load"
- Create local sandbox
C:\> svn checkout file:///c:/svn/repo1 c:\project
- Copy Subversion module files for Apache
C:\> copy c:\Progra~1\Subver~1\bin\*.so c:\progra~1\apache~1\apache2\modules
You may also need to manually transfer the DLL files from the Subversion installation directory. If the Apache service will not start, or reports an error loading mod_dav_svn.so, you will need to do this. They contain, among other things, the Berkeley DB. This is all you need to do for the DLLs:
C:\> copy c:\progra~1\subver~1\bin\*.dll c:\progra~1\apache~1\apache2\modules
Make sure you don't have Apache 2.0.52 (mod_dav_svn.so is not compatible with that version, upgrade to 2.0.58 or newer).
- Create password file (w/user 'admin')
C:\> c:\progra~1\apache~1\apache2\bin\htpasswd -cm c:\svn\.htaccess admin
- Configure Apache (edit httpd.conf) 11.1. Restrict access/lockdown as appropriate
11.2. Add Modules to httpd.conf
11.1.1. Uncomment:LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so
11.1.2. Add (after):# Subversion LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
11.1.3. Install Apache as Service (IF NOT WORKING when installed to C:)C:\Progra~1\Apache~1\Apache2\bin\Apache -k install -n "Apache2"
11.3. Add location root for multiple repositories# Subversion <Location /svn> DAV svn # any /svn/foo URL will map to a repository C:/svn/foo # I've only got it working using SVNPath!! SVNParentPath C:/svn AuthType Basic AuthName "Subversion repository" AuthUserFile c:/svn/.htaccess Require valid-user </Location>
11.4. Add cgi handler, Uncomment:AddHandler cgi-script .cgi
- Restart Apache.
Note: If you get an error message saying that the svn modules are garbled when starting apache via the start menu icons, this is probably due to the version of apache used to compile the modules shipped with subversion (and copied in step 9) being different. The modules shipped with version 1.3.2 of subversion (the latest at the time of writing) need version 2.0 of the server and not 2.2.
- Test your install of Subversion http://[hostname]:80/svn/repo1
Note: If you are unable to login, and everything seems to work, then try using a repository that Tortoise created. I burned several hours trying to get this to work until I tried a different repository. -jhopping
- Add users to password file
C:\> c:\progra~1\apache~1\apache2\bin\htpasswd -m c:\svn\.htaccess user
Install Trac Prerequisites
(Please note: pay attention to download exactly the versions mentioned here. Do not simply download the latest stable versions. Otherwise you will probably run into several issues.)
- Install Python
Please use Python 2.3 and not 2.4, because the Subversion bindings for Python (that are a few lines down) currently are only available for 2.3 (look here for the current status of the bindings)
If you desperately want it to work with Python 2.4, this trick seems to work. Install the Subversion bindings for Python 2.3 in the Python 2.4 site-packages directory. Find all dll files inte the directory \site-packages\libsvn with a name in the form: _*.dll. Now use your hexeditor of choice and replace all instances of "python23.dll" with "python24.dll" in the dll files (There's just one occurance in each file).
Beginning with version 1.4, the Subversion team has actually released bindings for Python 2.4. You can download them here.
Add C:\Python23 to the path
- Install Subversion Python Bindings
Download svn-win32-1.X.X_py.zip from the Subversion site.
Extract and copy the libsvn and svn directories to C:\Python23\Lib\site-packages
Note : it is very important to use the python bindings for the exact version of Subversion you have installed. e.g. when running svn 1.2.3, make sure to use svn-win32-1.2.3_py.zip instead of the zip mentioned above. Otherwise, you will run into problems (loading dlls etc.).
- Install docutils (optional)
This is only required if you want to support Restructured text wiki markupexpand and run from the expanded docutils-xxx directory > C:\python23\python setup.py install
- Install SQLite (optional)
Copy sqlite.exe to C:\Program Files\SQLite
This is really optional - you only need this if you want to start poking around in the sqlite database because something's gone wrong.
- Install PySQLite
Download and install pysqlite-1.1.6.win32-py2.3.exe
or pyPgSQL if you are using PostgreSQL http://pypgsql.sourceforge.net/
Download and install pyPgSQL-2.4.win32-py2.3.exe
NB. Make sure you use v1.x, not 2.x, because the module is renamed from sqlite to pysqlite in v2.x, so the trac installer will fail if you use pysqlite 2.x
Note: If using XAMPP (http://www.apachefriends.org/en/xampp-windows.html) to jumpstart setup you may encounter a problem. XAMPP bundles Python in with their distro and does not update the registry to denote the Python install directory (as I suppose is done during a default install of Python). This missing registry key prevents the pysqlite-X.X.X.win32-pyX.X.exe installer from running successfully. The install program will state that it can't find Python installed on your system. To fix this issue, simply add the following key to the Windows registry.
After creating this key, you should have a "(Default)" string variable which is created automatically. This variable is created with a value of NULL. Set this variable to the root directory of your Python installation. For example:
This should allow you to proceed along with the pysqlite installation.
- Install ClearSilver
http://www.clearsilver.net download clearsilver_python-0.9.12-win32.zip
Copy neo_cgi.pyd into C:\Python23\Lib\site-packages Alternatively, grab unofficial installers for ClearSilver 0.9.14 from http://clearsilver.yi.org/.
- Install eGenix.com mx Extensions for Python (if using PostgreSQL)
Download and install http://www.egenix.com/files/python/eGenix-mx-Extensions.html.
The 'initenv' command in trac-admin needs this library to create the Trac database (At least it did when using a PostgreSQL back end).
- Install Trac
python ./setup.py install
Fix a few things
- Define how the CGI script is called
23.1 Copy CGIC:\> copy c:\python23\share\trac\cgi-bin\trac.cgi c:\progra~1\apache~1\apache2\cgi-bin
Use a text editor such as notepad to open trac.cgi and ensure the first line contains the correct path for Apache to find python.
23.2 Alternatively, define a global Python handler for
If you often update your Trac installation (following trunk development), and do not want to customize the
trac.cgifile, you may want to define a global handler for
.cgiscripts, using the
23.2.1. Add the following line to your Apache configuration file:<Directory "/Path/To/Trac/cgi-bin"> ScriptInterpreterSource Registry-Strict </Directory>
23.2.2. Add the following key to your Windows registry[HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command] "@"="c:\\\\Programs\\\\Python\\\\python.exe"
Do not forget to update the path to your actual Python installation directory
Configure Trac DB
The trac database can be named to match the subversion repository it is working with, which is especially useful if more than one repository will ever be created. In this example
"trac.db" would read as
- Run trac-admin
C:\Python23\Scripts> python trac-admin c:/svn/trac.db
I found i had to do:
C:\Python23> python scripts/trac-admin c:/svn/trac.db
Note: The latter path is needed if python is not found in the environmental variable PATH.
- Initialize DB
Trac [c:/svn/trac.db]> initenv
Enter project name Project Database connection string [sqlite:db/trac.db]> (Just press enter to accept default) Enter path to repository c:\svn\repo1 Enter path to templates c:\Python23\share\trac\templates
See TracEnvironment for help with these settings.
If you get an error here stating that libdb42.dll was not found, copy [SVN PATH]\bin\libdb42.dll to [PYTHON PATH]\lib\libsvn\, then try again.
If you are using PostgreSQL and you get an error stating that libpq.dll cannot be found, add the PostgreSQL bin directory to your path (ex: C:\Program Files\PostgreSQL\8.1\bin).
If you get an error like "ImportError: No module named svn" you are missing the path to the SVN Python hooks in the PYTHONPATH environment variable. eg.
…assuming you installed the hooks for SVN1.2.3.
To get this step done the right way, you have to understand that the trac database is not the svn repository.
For example if you have your svn repository located in c:\svn\repo1 (like supposed by this tutorial), you'll probably want to name your trac database c:\trac\repo1. You would then call "python trac-admin c:/trac/repo1" in your scripts directory and enter "c:\svn\repo1" as the "path to (svn) repository".
- 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
- Edit httpd.conf:
Add: (copy this - there's a typo in Edgewall's version)
Edit PYTHONPATH to point to your install of SVN bin
# TRAC Alias /trac "C:/Python23/share/trac/htdocs" <Location /cgi-bin/trac.cgi> SetEnv TRAC_ENV "c:/svn/trac.db" SetEnv PYTHONPATH "C:/Program Files/Subversion/bin" # if you are running Apache as a user other than System, the TMP variable # needs to be set to a place where that user can write scratch files. Make # sure that this directory is created and writable by that user. # SetEnv TMP "c:/svn/trac.db/tmp </Location> <Location /cgi-bin/trac.cgi/login> AuthType Basic AuthName "Project" AuthUserFile C:/svn/.htaccess Require valid-user </Location> <Directory "C:/Python23/share/trac/htdocs"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory>
If you want to configure a friendly URL, like http://hostname/trac, the following configuration can be used instead of the appropriate sections above
# TRAC # Transfer serving up of static content to Apache Alias /trac/chrome/common "C:/Program Files/Python2.3.5/share/trac/htdocs" # Alias for the friendly URL ScriptAlias /trac "C:/Program Files/Python2.3.5/share/trac/cgi-bin/trac.cgi" <Location "/trac"> SetEnv TRAC_ENV "c:/svn/trac.db" SetEnv PYTHONPATH "C:/Program Files/Subversion/bin" # if you are running Apache as a user other than System, the TMP variable # needs to be set to a place where that user can write scratch files. Make # sure that this directory is created and writable by that user. # SetEnv TMP "c:/svn/trac.db/tmp </Location> <Location "/trac/login"> AuthType Basic AuthName "trac" AuthUserFile C:/svn/.htaccess Require valid-user </Location>
Note: if you get an error "Authentication information not available." after clicking "login", refer to #2258
Alternatively you could set up the authorization to use your NT domain login if you are running an NT Domain. This bit of Apache config replaces the <Location /cgi-bin/trac.cgi/login> given above.<Location /cgi-bin/trac.cgi/login> #NT Domain auth config AuthType SSPI SSPIAuth On SSPIAuthoritative On SSPIOfferBasic On SSPIOmitDomain Off # following line squishes bug #1168 if IE has troubles editing wiki pages. SSPIBasicPreferred On AuthName "Project" Require valid-user </Location>
You'll also need the sspi_auth_module on your system and loaded like this…LoadModule sspi_auth_module modules/mod_auth_sspi.so
You must download and install this module. It can be found here: http://mod-auth-sspi.sf.net/
Or compile it into Apache. Note when adding permissions and authenticating against a domain you may need to use the following syntax complete with quotes as seen in #1055.
- permission add "DOMAIN\username" TRAC_ADMIN
Note: Internet Explorer may be in trouble with an Apache server running SSPI authentication. See #1343
With example above, you must specify user name like "DOMAIN\username" If you hate "DOMAIN\username" format,
SSPIOmitDomainoption is usefull. Set it ON!SSPIOmitDomain On
If this option is ON, the mod_auth_sspi passes authentication name to an Apache server without a domain part. As result, you can manage user names with simply 'username' instead of 'DOMAIN\username' in apache password file and
trac-admincommand, and also, it is used by Trac for reporter name, author and so on.
- permission add username TRAC_ADMIN
But remember that you must specify "DOMAIN\username" format on authentication dialog although this option is ON.
Note: Older version of mod_auth_sspi (like http://tortoisesvn.tigris.org/mod_auth_sspi.zip) doesn't support
SSPIOmitDomainand has bug for basic authentication. 1.0.2 introduced above is recommended.
- Restart Apache.
- Hold your breath, test Trac install http://[hostname]:80/cgi-bin/trac.cgi
If it doesn't work, then running Apache from the command-line will give you a few clues.
If your page seems to be lacking stylesheets, please check the alias of /trac in apache. Otherwise you've probably run into a known Apache bug described (and worked around) here.
It is possible you have to add Full NTFS file permissions to user NT Authority\System on Trac folder, otherwise you could get an error.
- In order for Trac to syntax highlight code, you must download and install Enscript. After installing Enscript, you will need to add the path to the enscript executable to the Windows PATH environment variable. Note: If Apache is running as a service you will need to reboot the machine for it to receive the updated PATH setting.
Optional pre- and post-commit hooks for Subversion
- In order to use pre- and post-commit hooks with Subversion on Windows, please refer to the files described in #1602, as the these files are not commited into the trunk as of version 0.9-dev.
The files you need are "pre-commit.2.bat", "post-commit.2.bat", "trac-pre-commit-hook_4bat.2" and "trac-post-commit-hook_4bat.2". The pre-commit hook makes it a requirement to reference a ticket before commiting the changes.
Place the desired ".bat" and "trac-" files in your Subversion repository "hooks" directory and configure the ".bat" file for your system (remove the ".2" from the filenames ofcourse). For more information on hooks, read the Hook Scripts section of the Subversion book.
- Don't forget to lock down the security on the box!
- If the svn page would not work properly with saying that DLL is missing, FIRST try to reboot the system and if that does not work, copy the three DLL's - libdb42.dll - libeay32.dll - ssleay32.dll from your [Subversion]\bin directory to your system directory (most likely C:\Windows\system32).
Upgrading from Trac 0.84 to 0.9-beta1 on Windows
This section builds off the generic Trac upgrade instructions, so you may want to keep that open to use as supplementary reading material.
- Download Windows Installer file
- Backup old version of Trac:
> move C:\Python23\Lib\site-packages\trac C:\Python23\Lib\site-packages\trac-0.8.4 > move C:\Python23\share\trac C:\Python23\share\trac-0.8.4 > move C:\Program Files\Apache Group\Apache2\cgi-bin\trac.cgi C:\Program Files\Apache Group\Apache2\cgi-bin\trac-0.8.4.cgi > xcopy /x /e /i C:\svn\trac.db C:\svn\trac-0.8.4.db\
- Run the Trac Windows Installer
- Run these commands
> cd C:\Python23\Scripts > python trac-admin C:\svn\trac.db upgrade > python trac-admin C:\svn\trac.db wiki upgrade
- If using CGI, copy trac.cgi to Apache directory.
> copy C:\Python23\share\trac\cgi-bin\trac.cgi C:\Program Files\Apache Group\Apache2\cgi-bin\trac.cgi
- Open and edit C:\Program Files\Apache Group\Apache2\cgi-bin\trac.cgi. Change the first line from:
- Point your web browser to the Trac site. That should be it!
- Daragh Fitzpatrick
- Alex Wolfe
- Tim Browse
- Sid Wiesner
- Amit Budhu
- Rodney Beck
- Javier Nievas
After a fresh install, trying to access either the Timeline or Browse Source tabs results in an internal error:
Traceback (most recent call last): File "C:\Local\Python23\Lib\site-packages\trac\core.py", line 531, in cgi_start real_cgi_start() File "C:\Local\Python23\Lib\site-packages\trac\core.py", line 526, in real_cgi_start dispatch_request(path_info, args, req, env) File "C:\Local\Python23\Lib\site-packages\trac\core.py", line 439, in dispatch_request module = module_factory(args, env, database, req) File "C:\Local\Python23\Lib\site-packages\trac\core.py", line 172, in module_factory import sync File "C:\Local\Python23\Lib\site-packages\trac\sync.py", line 22, in ? from svn import fs, util, delta, repos, core File "C:\Local\Python23\lib\svn\fs.py", line 28, in ? import libsvn.fs File "C:\Local\Python23\lib\libsvn\fs.py", line 4, in ? import _fs ImportError?: DLL load failed: The specified module could not be found.
An easy solution would be to copy dlls at svn\bin\*.dll to cgi-bin directory. then it works well. Before copying any DLLs, first try to reboot the system. In most cases, the internal system error problem disappear after a simple system reboot.
Guía en Español
Guía de instalación de Trac en Windows en Español. Aquí. Some help for Spanish speakers installing Trac for Windows.
This is one of the best docs on how install a system. Thank you very much. The only thing I don't understand is what should I do "to lock down the security on the box". Excuse me, I'm a begineer in this things, Could somebody explain a little bit? Thanks, a lot!
This badly needs a distro
The large number of components to download and long list of installation steps puts me off bothering to install Trac. I love Trac and use it at work but I just don't have the time/patience to work through all these steps. What's obviously needed is a single distro with everything preconfigured and tested for Win32/Mac/Linux. I think this would also reduce the inevitable support requests from such as complex install. I think the ideal might be a Trac installation addon for each XAMPP distro.
I agree, this needs a distro. I would be willing to help if such a thing were started. http://www.RicharddeCosta.com
New Python Bindings
New python bindings and isntallers have been made for 2.4 python and newer subversion releases here for instance. Also with SVNPath in the httpd.conf if your full path has spaces you may want to put it in double quotes.
The trac.cgi file is encoded as UTF-8 which causes errors for apache when it tries to execute it, rename the file to ~trac.cgi copy the contents of the file into a text document and save as trac.cgi and then it should become executable.