== Windows Installation Instructions for Subversion w/Trac 0.9.4 == For:: * Windows Server 2003 SP1 * IIS 6 * Trac 0.9.4 There are some documented issues regarding running Trac on Microsoft's Internet Information Server (IIS), however it does work (albeit slowly). Refer to the following issues for details: #692 #693 and #697. ---- Note 1: Before continuing to set up Trac to run using IIS6, be warned that python running under IIS6 is painfully slow. It is recommended that the use of [source:trunk/README.tracd#latest tracd] be used for performance reasons. See http://lazutkin.com/blog/2006/feb/18/setting-tools-windows/ -> Section "Trac" -> Step 4. This results in a ''significant'' performance boost over CGI. ---- Note 2: This example installs to F: (for extra points, then goes DarkReign hard with a separate application pool and so on.) ---- Note 3: If you want to use Trac 0.10 please take a look [http://groups.google.com/group/trac-users/browse_thread/thread/98dbacece22365e2/1385d5e1e43a938c?lnk=gst&q=IIS&rnum=1#1385d5e1e43a938c here]. Do not make the modifications described in this article. ---- === Arm Yourself === 1. Get & Read book http://svnbook.red-bean.com === Install Subversion Pre-Requisites === 2. Download and Install Python (Get version 2.3.5, because v2.4 doesn't have appropriate SVN plugins available). http://www.python.org/download/releases/2.3.5/ Add F:\Python23 to path Note that installing to a path that contains spaces is likely to break the install (iis6 doesn't seem to like cgi interpreters with spaces in their path). 3. Install IIS Control panel, Configure server roles... 4. Install Subversion http://subversion.tigris.org (remember to get the python bindings as well) 5. Install docutils http://docutils.sourceforge.net/ {{{ expand and run from the expanded docutils-xxx directory > F:\python23\python install.py }}} === Create Repository === 6. Create repository {{{ F:\> svnadmin create f:\tracsvn --fs-type fsfs }}} The bdb repo type doesn't work well with a cgi trac on windows (possibly locking?). The fsfs type works quite well though. 8. Create skeleton repository structure in f:\temp\project Example: {{{ /project /vendor /tags /trunk files /projectname /branches /tags /trunk files }}} 9. Build repository tree {{{ f:\> svn import f:\temp\project file:///f:/tracsvn/ -m "Initial Load" }}} 10. Create local SVN sandbox {{{ f:\> svn checkout file:///f:/svn/repo1 f:\project }}} === Configure IIS === 11. Create the Service-Trac (local) user * Add Service-Trac to the IIS_WPG (local) group 12. Allow the Service-Trac user to run cgi scripts. * Grant Service-Trac the following permissions in the 'Local Security Policy' Administrative Tool: * Security Settings > Local Policies > User Rights Assignment > Adjust Memory Quotas for a process * Security Settings > Local Policies > User Rights Assignment > Replace a process level token * Together these permission allow the Service-Trac user to run cgi scripts. * See [http://www.microsoft.com/resources/documentation/iis/6/all/proddocs/en-us/ca_configcgi.mspx] for more information. 13. Add a Python CGI web service extension to IIS In the IIS control panel add a new web service extension. The required file is [F:\Python23\python.exe -u "%s" %s]. You will also need to enable this extension. 14. IIS virtual directories Add a virtual directory for /trac in the IIS control panel. It doesn't need execute permissions of any description as that will be taken care of by /trac/cgi-bin. Map this to [F:\Python23\share\trac\htdocs]. Ensure that Anonymous/Windows authentication is set as per your usage requirements. Add a cgi-bin vdir under /trac in the IIS control panel. It needs script execute permissions. Map this to [F:\Python23\share\trac\cgi-bin]. 15. IIS Application Pool Add a new application pool in the IIS control panel. Change the Identity of the new pool to Configurable and enter the details for the Service-Trac user you defined earlier. Change the Application settings of the /trac/cgi-bin vdir: click Configuration and select the Mappings tab. Add a new mapping. * Executable: [F:\Python23\python.exe -u "%s" %s] - note that this must be identical to the web service extension added earlier * Extension: [cgi] * Verbs: All verbs * Script Engine: checked * Verify that file exists: unchecked Change the Application Pool setting of the cgi-bin vdir to the pool you just created. 16. Fix up permissions Change the ownership of, or give Full-Control permissions on F:\tracsvn to Service-Trac. You may also need to change the ownership or grant write/modify on F:\Python23\Lib\site-packages\trac to Service-Trac (so it can write pyc files). Service-Trac will need read access to F:\Python23\share\trac === Install Trac Prerequisites === 17. Install Subversion Python Bindings (Get from same download page as Subversion - http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91. Currently only supports Python 2.3 - NOT 2.4) [[br]]Copy libsvn and svn directories to F:\Python23\Lib 18. Install SQLite http://www.sqlite.org/download.html [[br]]Copy sqlite.exe to F:\Program Files\SQLite This is really optional. Don't let it mess your disk unless something exceptional not described here happens. 19. Install PySQLite http://www.initd.org/tracker/pysqlite 20. Install ClearSilver http://www.clearsilver.net 21. Install Trac http://projects.edgewall.com/trac/wiki/TracDownload Use the Windows installer to avoid having to manually install Trac with Python. === Modify a few Python scripts to cater for peculiarities specific to IIS === 22. Fix the CGI In [F:\Python23\Share\Trac\cgi-bin\trac.cgi] modify the section between the try/except block to be as follows: {{{ try: from trac.web import cgi_frontend # PATCH IIS6 - start import os os.environ['TRAC_ENV'] = 'F:\\tracsvn\\Trac.db' # PATCH IIS6 - end cgi_frontend.run() except Exception, e: }}} The TRAC_ENV line is important as IIS6 won't pass this environment variable to the script when it runs. 23. Fix Python file - api.py In [F:\Python23\Lib\site-packages\trac\web\api.py], in the [redirect] function on the Request class, replace the entire function with: {{{ def redirect(self, url): """Send a redirect to the client, forwarding to the specified URL. The `url` may be relative or absolute, relative URLs will be translated appropriately. """ base_url = '%s://%s' % ("http", os.getenv('SERVER_NAME')) if self.session: self.session.save() # has to be done before the redirect is sent self.send_response(302) if not url.startswith('http://') and not url.startswith('https://'): # Make sure the URL is absolute url = absolute_url(self, url) self.send_header('Location', base_url + url) self.send_header('Content-Type', 'text/plain') self.send_header('Pragma', 'no-cache') self.send_header('Cache-control', 'no-cache') self.send_header('Expires', 'Fri, 01 Jan 1999 00:00:00 GMT') self._send_cookie_headers() self.end_headers() if self.method != 'HEAD': self.write('Redirecting...') raise RequestDone }}} 24. Fix Python file - cgi_frontend.py In [F:\Python23\Lib\site-packages\trac\web\cgi_frontend.py], class CGIRequest, change the real_cgi_start function where it says : {{{ self.path_info = self.__environ.get('PATH_INFO', '') }}} Change this to: {{{ # IIS 6 Change self.path_info = self.__environ.get('PATH_INFO', '') self.path_info = self.path_info.replace(os.getenv('SCRIPT_NAME'),"") # End IIS 6 Change }}} === 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. However, I'm not going to try that here (re: DarkReign hard). 25. Run trac-admin {{{ f:\Python23\Scripts> python trac-admin f:/tracsvn/trac.db }}} 26. Initialize DB Note: Before performing this step, ensure that your current user account (ie. the account you are running the command prompt under) has read/write permissions to your SVN directory (f:/tracsvn/) in order to create the Trac Sqlite database. {{{ Trac [f:/tracsvn/trac.db]> initdb }}} or {{{ Trac [f:/tracsvn/trac.db]> initenv }}} {{{ Enter project name Project Database Connection String sqlite:db/trac.db Enter path to repository f:\tracsvn\ Enter path to templates f:\Python23\share\trac\templates }}} 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. 27. (BUG) Load Wiki {{{ Trac [f:/tracsvn/trac.db]> wiki load f:/python23/share/trac/wiki-default }}} 28. Add administrative permissions (the below adds all permissions for 'admin' user) {{{ Trac [f:/tracsvn/trac.db]> permission add admin TRAC_ADMIN }}} Note that if you're using windows authentication with iis6 you can grant permissions to windows users here. Eg. {{{ Trac [f:/tracsvn/trac.db]> permission add STAR\\Administrator TRAC_ADMIN }}} If your iis server's windows network name is "STAR", or your iis server is in the "STAR" domain. === Finally... === 29. Install Subversion clients as necessary (try [http://rapidsvn.tigris.org RapidSVN] & [http://tortoisesvn.tigris.org/ TortoiseSVN]) 30. Don't forget to lock down the security on the box! 31. Now go get a *real* drink