| 1 | = Running Trac on IIS 6 using AJP = |
| 2 | |
| 3 | For: |
| 4 | * Windows Server 2003 SP2 |
| 5 | * IIS 6 |
| 6 | * Trac 0.11 |
| 7 | |
| 8 | Contributed by:[[BR]] |
| 9 | Wilfred Berger, [http://www.stala.bwl.de Statistisches Landesamt], Stuttgart, Germany |
| 10 | |
| 11 | == Why this? == |
| 12 | If you want to run Trac on a Windows system, your first choice will be running [http://lazutkin.com/blog/2006/feb/18/setting-tools-windows/ tracd stand-alone].[[BR]] |
| 13 | This may be impossible for several reasons: |
| 14 | |
| 15 | * tracd does not support HTTPS. If you want to serve HTTPS, you will have to connect Trac to a common web server. |
| 16 | * If you want to mix Trac with other content in your web site, you will again have to connect Trac to another web server. |
| 17 | |
| 18 | In both cases, the web server on a Windows system will most probably be IIS. |
| 19 | |
| 20 | Generally, it is not a good idea to use CGI on a Windows system. CGI implies starting a new system process for every single request, which, on Windows, causes significant overhead and makes things slow. |
| 21 | |
| 22 | The following solution uses AJP. This protocol was developped for connecting Tomcat to a web server which is very similar to what we are doing here. |
| 23 | |
| 24 | == 1. Install Trac == |
| 25 | ... exactly as if you were going to run [http://lazutkin.com/blog/2006/feb/18/setting-tools-windows/ tracd stand-alone], with two exceptions: |
| 26 | |
| 27 | * Since port 80 will be occupied by IIS, choose a different port, including "`-p 8009`" to the tracd start command. |
| 28 | |
| 29 | Of course, 8009 is an example and you are free to use any other port as well.[[BR]] |
| 30 | At this point you should check whether Trac is running properly. |
| 31 | |
| 32 | * Use "`--protocol=ajp`" to make tracd use AJP instead of HTTP. |
| 33 | |
| 34 | Now you will get an error message indicating that module flup.server.ajp is missing. (If you don't, flup is already installed and you may skip th following step.) |
| 35 | |
| 36 | == 2. Install [http://trac.saddi.com/flup flup] == |
| 37 | |
| 38 | * Copy [http://trac.saddi.com/flup/flup-1.0-py2.5.egg flup-1.0-py2.5.egg] to C:\Python25\Scripts (or whatever may be your Python installation directory). |
| 39 | * Run `easy_install flup`. |
| 40 | |
| 41 | Now tracd should start without an error. |
| 42 | |
| 43 | == 3. Install [http://tomcat.apache.org/connectors-doc/reference/iis.html Tomcat AJP Connector for IIS] == |
| 44 | |
| 45 | * Set up the directory structure. |
| 46 | |
| 47 | We assume there will be a base directory named C:\AJP-Connector and three subdirectories bin, conf and logs. Of course, you may chooe anything else for the base directory. |
| 48 | |
| 49 | * Copy [http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.26/isapi_redirect-1.2.26.dll isapi_redirect-1.2.26.dll] to the bin subdirectory. |
| 50 | * Create a configuration file isapi_redirect-1.2.26.properties for the ISAPI redirector. |
| 51 | |
| 52 | This must be in the same directory as the DLL and have exactly the same name but with a .properties extension. The configuration file should contain this: (be sure to replace "C:\AJP-Connector" with your actual directory) |
| 53 | |
| 54 | {{{ |
| 55 | # Configuration file for the ISAPI Redirector |
| 56 | |
| 57 | # The path to the ISAPI Redirector Extension, relative to the website |
| 58 | # This must be in a virtual directory with execute privileges |
| 59 | extension_uri=/AJP-Connector/isapi_redirect-1.2.26.dll |
| 60 | |
| 61 | # Full path to the log file for the ISAPI Redirector |
| 62 | log_file=C:\AJP-Connector\logs\isapi_redirect.log |
| 63 | |
| 64 | # Log level (debug, info, warn, error or trace) |
| 65 | log_level=info |
| 66 | |
| 67 | # Full path to the workers.properties file |
| 68 | worker_file=C:\AJP-Connector\conf\workers.properties |
| 69 | |
| 70 | # Full path to the uriworkermap.properties file |
| 71 | worker_mount_file=C:\AJP-Connector\conf\uriworkermap.properties |
| 72 | }}} |
| 73 | |
| 74 | * Create the workers.properties file with the following content: (replace the host name and port if necessary) |
| 75 | |
| 76 | {{{ |
| 77 | # Define 1 real worker |
| 78 | worker.list=trac |
| 79 | # Set properties for trac (ajp13) |
| 80 | worker.trac.type=ajp13 |
| 81 | worker.trac.host=localhost |
| 82 | worker.trac.port=8009 |
| 83 | worker.trac.socket_keepalive=0 |
| 84 | }}} |
| 85 | |
| 86 | * Create the uriworkermap.properties file with the following content: (insert the proper trac directory names) |
| 87 | |
| 88 | {{{ |
| 89 | /your-first-trac-directory*=trac |
| 90 | /your-second-trac-directory*=trac |
| 91 | }}} |
| 92 | |
| 93 | * Define the virtual directory for IIS |
| 94 | * Start the IIS Manager. (This is normally found at %!SystemRoot%\system32\inetsrv\iis.msc). |
| 95 | * Define a virtual directory named "AJP-Connector", pointing to your bin subdirectory, with permissions to execute executables (not only scripts). |
| 96 | * Allow execution of the DLL as Web Service Extension |
| 97 | * In the IIS Manager, open Web Service Extensions. |
| 98 | * Define a new Web Service Extension called AJP-Connector (or whatever you want). |
| 99 | * Add C:\AJP-Connector\bin\isapi_redirect-1.2.26.dll to the required files (replace "C:\AJP-Connector" with your actual directory). |
| 100 | * Set extension status to Allowed. |
| 101 | * Click OK. |
| 102 | |
| 103 | == 4. Enjoy == |
| 104 | That's everything I did and it works. |