annotate examples/trac/wiki-default/TracModPython @ 39:93b4dcbafd7b trunk

Copy Trac to main branch.
author cmlenz
date Mon, 03 Jul 2006 18:53:27 +0000
parents
children
rev   line source
39
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
1 = Trac and mod_python =
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
2
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
3 Trac supports [http://www.modpython.org/ mod_python], which speeds up Trac's response times considerably and permits use of many Apache features not possible with [wiki:TracStandalone tracd]/mod_proxy.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
4
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
5 == Simple configuration ==
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
6
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
7 If you just installed mod_python, you may have to add a line to load the module in the Apache configuration:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
8 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
9 LoadModule python_module modules/mod_python.so
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
10 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
11
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
12 A simple setup of Trac on mod_python looks like this:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
13 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
14 <Location /projects/myproject>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
15 SetHandler mod_python
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
16 PythonHandler trac.web.modpython_frontend
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
17 PythonOption TracEnv /var/trac/myproject
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
18 PythonOption TracUriRoot /projects/myproject
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
19 </Location>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
20 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
21
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
22 Note that the option `TracUriRoot` may or may not be necessary in your setup. Try without first, and if the URLs produced by Trac look wrong or if Trac does not seem to recognize the URLs correctly, add the `TracUriRoot` option.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
23
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
24 Configuring authentication works the same as for [wiki:TracCgi#AddingAuthentication CGI]:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
25 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
26 <Location "/projects/myproject/login">
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
27 AuthType Basic
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
28 AuthName "myproject"
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
29 AuthUserFile /var/trac/myproject/.htaccess
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
30 Require valid-user
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
31 </Location>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
32 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
33
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
34 If the Trac installation isn't installed in your Python path, you'll have to tell Apache where to find the Trac mod_python handler using the `PythonPath` directive:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
35 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
36 <Location /projects/myproject>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
37 ...
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
38 PythonPath "sys.path + ['/path/to/trac']"
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
39 ...
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
40 </Location>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
41 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
42
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
43
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
44 == Setting up multiple projects ==
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
45
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
46 The Trac mod_python handler handler supports a configuration option similar to Subversion's `SvnParentPath`, called `TracEnvParentDir`:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
47 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
48 <Location /projects>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
49 SetHandler mod_python
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
50 PythonHandler trac.web.modpython_frontend
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
51 PythonOption TracEnvParentDir /var/trac
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
52 PythonOption TracUriRoot /projects
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
53 </Location>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
54 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
55
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
56 When you request the `/projects` URL, you will get a listing of all subdirectories of the directory you set as `TracEnvParentDir`. Selecting any project in the list will bring you to the corresponding Trac environment.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
57
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
58 If you don't want to have the subdirectory listing as your projects home page you can use a
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
59 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
60 <LocationMatch "/.+/">
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
61 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
62
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
63 This will instruct Apache to use mod_python for all locations different from root while having the possibility of placing a custom home page for root in your !DocumentRoot folder.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
64
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
65 You can also use the same authentication realm for all of the projects using a `<LocationMatch>` directive:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
66 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
67 <LocationMatch "/[^/]+/login">
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
68 AuthType Basic
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
69 AuthName "Trac"
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
70 AuthUserFile /var/trac/.htaccess
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
71 Require valid-user
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
72 </LocationMatch>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
73 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
74
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
75 == Virtual Host Configuration ==
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
76
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
77 Below is the sample configuration required to set up your trac as a virtual server (i.e. when you access it at the URLs like
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
78 !http://trac.mycompany.com):
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
79
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
80 {{{
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
81 <VirtualHost * >
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
82 DocumentRoot /var/trac/myproject
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
83 ServerName trac.mycompany.com
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
84 <Directory />
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
85 SetHandler mod_python
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
86 PythonHandler trac.web.modpython_frontend
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
87 PythonOption TracEnv /var/trac/myproject
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
88 PythonOption TracUriRoot /
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
89 </Directory>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
90 <Location /login>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
91 AuthType Basic
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
92 AuthName "MyCompany Trac Server"
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
93 AuthUserFile /var/trac/myproject/.htusers
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
94 Require valid-user
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
95 </Location>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
96 </VirtualHost>
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
97 }}}
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
98
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
99 == Troubleshooting ==
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
100
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
101 === Form submission problems ===
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
102
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
103 If you're experiencing problems submitting some of the forms in Trac (a common problem is that you get redirected to the start page after submission), check whether your {{{DocumentRoot}}} contains a folder or file with the same path that you mapped the mod_python handler to. For some reason, mod_python gets confused when it is mapped to a location that also matches a static resource.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
104
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
105 === Using .htaccess ===
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
106
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
107 Although it may seem trivial to rewrite the above configuration as a directory in your document root with a `.htaccess` file, this does not work. Apache will append a "/" to any Trac URLs, which interferes with its correct operation.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
108
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
109 It may be possible to work around this with mod_rewrite, but I failed to get this working. In all, it is more hassle than it is worth. Stick to the provided instructions. :)
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
110
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
111 === Win32 Issues ===
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
112
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
113 If you run trac with mod_python (3.1.3 or 3.1.4) on Windows,
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
114 uploading attachments will '''not''' work.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
115 This is a known problem which we can't solve cleanly at the Trac level.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
116
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
117 However, there is a workaround for this at the mod_python level,
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
118 which is to apply the following patch [http://projects.edgewall.com/trac/attachment/ticket/554/util_py.patch attachment:ticket:554:util_py.patch]
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
119 to the (Lib/site-packages)/modpython/util.py file.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
120
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
121 If you don't have the `patch` command, that file can be replaced with the [http://svn.apache.org/viewcvs.cgi/httpd/mod_python/trunk/lib/python/mod_python/util.py?rev=103562&view=markup fixed util.py] (fix which, although done prior to the 3.1.4 release, is ''not''
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
122 present in 3.1.4).
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
123
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
124 === OS X issues ===
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
125
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
126 When using mod_python on OS X you will not be able to restart Apache using `apachectl restart`. This is apparently fixed in mod_python 3.2, but there's also a patch available for earlier versions [http://www.dscpl.com.au/projects/vampire/patches.html here].
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
127
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
128 ----
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
129 See also TracGuide, TracInstall, TracCgi, TracFastCgi
Copyright (C) 2012-2017 Edgewall Software