Introduction
To install Trac 1.0.1 on a Windows 8.1 installation, I used the following dependencies:
Apache HTTPD | 2.2.25 (32bit) |
Python | 2.7.8 (32bit) |
setuptools | 5.4.1 |
mod_wsgi | 3.5.ap22.win32-py2.7 (32 bit) |
Subversion | 1.8.9 (r1591380) |
Python Subversion bindings | svn-win32-1.8.9 |
- Be sure to keep the same architecture (32 or 64 bit) for all components. Don't mix them up, as you will get conflicts. In this tutorial, I used 32 bit installers.
- I assumed Subversion is already installed, and your repository is located on the same machine of the Trac server (repository created in C:\SVN). Authentication is performed based on HTTPD Basic auth file (file located at C:\SVN\conf\svn-auth-file)
Installing Python
- Python is required to startup Trac as Trac is built on top of Python
- Download from: https://www.python.org/download/
- Choose version: 2.7.8 - 32 bit
- When installing, make sure you select: Install for all users, and not the current user. If you don't do this, the Apache service will not be able to access Python eggs
- When installing, also check Add python.exe to Path
- After installation, restart your machine so the new system variable Path will be in memory. Otherwise, you cannot use the python.exe command from whatever folder you're currently working in
Installing setuptools
- setuptools is required to install a Python package like Trac. setuptools will have a look at the dependencies, and will automatically download/install the dependencies for you (e.g.: Genshi)
- Download from: https://pypi.python.org/pypi/setuptools
- Choose version: 5.4.2 - Windows 7
- Download the file ez_setup.py
- When downloaded, double click the file to install setuptools
- Add C:\Python27\Scripts to Path variable
- After installation, restart your machine so the new system variable Path will be in memory. Otherwise, you cannot use the easy_install.exe command from whatever folder you're currently working in (and also later on trac-admin.exe)
Installing trac
- Open command prompt and type: $ easy_install trac
- The command prompt will install Trac and its dependencies. At the end, a message Congratulations! will be visible in the command prompt
Create trac environment
- Open command prompt and type: $ trac-admin C:\Trac initenv
- Follow steps to create your project
Configuring mod_wsgi
- mod_wsgi is used to connect Trac with Apache HTTPD. In this case, you won't need to run Trac on a specific port like 8000
- Download from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
- Choose version: mod_wsgi‑3.5.ap22.win32‑py2.7.zip
- Unzip and move contents to C:/Program Files/Apache Software Foundation/Apache2.2/modules/. Make sure the Apache service can read this .so file
- Create Apache HTTPD directories by executing the command: $ trac-admin C:\Trac deploy C:\Temp
- Copy C:\Temp\cgi-bin and C:\Temp\htdocs to C:\Trac
- Enable module mod_wsgi.so in Apache HTTPD by adding the following the line in the load modules section: LoadModule wsgi_module modules/mod_wsgi.so
- Add the following configuration at the bottom of the httpd.conf file
WSGIScriptAlias /trac C:\Trac\cgi-bin\trac.wsgi # Process Trac requets Alias /trac/chrome/common C:\Trac\htdocs\common # Serve static content directly from disk (don't send to .cgi script) Alias /trac/chrome/site C:\Trac\htdocs\site # Serve static content directly from disk (don't send to .cgi script) <Directory C:\Trac\cgi-bin> WSGIApplicationGroup %{GLOBAL} Order allow,deny Allow from all </Directory> <Directory C:\Trac\htdocs> Order allow,deny Allow from all </Directory> <Location "/trac/login"> AuthType Basic AuthName "Trac" AuthUserFile C:\SVN\conf\svn-auth-file Require valid-user </Location>
- Restart Apache HTTPD and check if you can access: http://localhost/trac/
Remark on choosing the version of mod_wsgi. Don't use the ap24 version. I cannot explain why, but it gave me the following exception when starting up Apache HTTD. By downgrading to ap22, the exception disappeared:
Cannot load C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_wsgi.so into server: The specified module could not be found
Providing a user admin permissions
- It would be better to create groups, but for this simple tutorial, I use a command to make 1 user admin: $ trac-admin C:\Trac permission add #USERNAME# TRAC_ADMIN
Configuring Subversion as a repository (browser)
- To be able to let Trac communicate with Subversion, you need the Python SVN bindings
- Download from: http://alagazam.net/
- Choose version: svn-win32-1.8.9_py27.zip
- Extract contents of ZIP file to C:\Python27\Lib\site-packages
- Create a components section add the following lines to enable the SVN bindings:
[components] tracopt.versioncontrol.svn.* = enabled
- Login to Trac with an admin account and go to Admin > Repositories and add your SVN repository
- Open a command prompt and execute the following command to resync previous changesets: $ trac-admin C:\Trac repository resync #REPOSITORYNAME# (required for Timeline)
- You should also set up a post-commit hook on the repository to keep Trac in sync with your Subversion repository (required for Timeline). Go to C:\SVN\hooks and create a file post-commit.bat (copy it from the existing template). Add the following line at the bottom of the script: trac-admin C:\Trac changeset added #REPOSITORYNAME# $REV. File should look like:
#!/bin/sh REPOS="$1" REV="$2" TXN_NAME="$3" trac-admin C:\Trac changeset added #REPOSITORYNAME# $REV
- When you now click Browse source in Trac, you should be able to see your source code. The timeline will also be updated every time you make a commit
Comments
FYI: There seems to be a vulnerability in mod_wsgi 3.5 and fixed versions in the 4.x series don't work on Windows yet.
Apache mod_wsgi < 4.2.4 Privilege Dropping Privilege Escalation
http://www.tenable.com/plugins/index.php?view=single&id=76498
Thanks David for the tip. Should check this one indeed ...
Hi,
Some things are not clear for me.
For example, which svn did you download?
VisualSVN, etc. The thing is I tried everything but I couldn't make it work.
The stupid apache server doesn't start. Most likely I missed something, therefore, I would like to ask you if you can be a bit
more explicit in your steps(I am doing this for the first time and I can't make it work).
On another note, the mod_wsgi‑3.5.ap22.win32‑py2.7.zip file doesn't exist on the server.
Best regards,
I installed Subversion from: http://sourceforge.net/projects/win32svn/
As Dave stated on top, we should not be using mod_wsi 3.5 any longer. Try to use 4.4.11 (can be download from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi)
Add new comment