Changes between Version 1 and Version 2 of TracModPython
- Timestamp:
- Apr 13, 2011, 9:04:35 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracModPython
v1 v2 1 1 = Trac and mod_python = 2 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. 2 [[TracGuideToc]] 3 4 Trac supports [http://www.modpython.org/ mod_python], which speeds up Trac's response times considerably, especially compared to [TracCgi CGI], and permits use of many Apache features not possible with [wiki:TracStandalone tracd]/mod_proxy. 5 6 These instructions are for Apache 2; if you are still using Apache 1.3, you may have some luck with [trac:wiki:TracModPython2.7 TracModPython2.7]. 7 8 == A Word of Warning == 9 10 As of 16^th^ June 2010, the mod_python project is officially dead. If you are considering using mod_python for a new installation, '''please don't'''! There are known issues which will not be fixed and there are now better alternatives. Check out the main TracInstall pages for your target version for more information. 4 11 5 12 == Simple configuration == … … 10 17 }}} 11 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 12 45 A simple setup of Trac on mod_python looks like this: 13 46 {{{ 47 14 48 <Location /projects/myproject> 15 49 SetHandler mod_python 50 16 51 PythonHandler trac.web.modpython_frontend 17 52 PythonOption TracEnv /var/trac/myproject 18 53 PythonOption TracUriRoot /projects/myproject 19 </Location> 20 }}} 21 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. 23 24 Configuring authentication works the same as for [wiki:TracCgi#AddingAuthentication CGI]: 25 {{{ 26 <Location "/projects/myproject/login"> 54 Order allow,deny 55 Allow from all 56 </Location> 57 }}} 58 59 The option '''`TracUriRoot`''' may or may not be necessary in your setup. Try your configuration without it; if the URLs produced by Trac look wrong, if Trac does not seem to recognize URLs correctly, or you get an odd "No handler matched request to..." error, add the '''`TracUriRoot`''' option. You will notice that the `Location` and '''`TracUriRoot`''' have the same path. 60 61 The options available are 62 {{{ 63 # For a single project 64 PythonOption TracEnv /var/trac/myproject 65 # For multiple projects 66 PythonOption TracEnvParentDir /var/trac/myprojects 67 # For the index of multiple projects 68 PythonOption TracEnvIndexTemplate /srv/www/htdocs/trac/project_list_template.html 69 # A space delimitted list, with a "," between key and value pairs. 70 PythonOption TracTemplateVars key1,val1 key2,val2 71 # Useful to get the date in the wanted order 72 PythonOption TracLocale en_GB.UTF8 73 # See description above 74 PythonOption TracUriRoot /projects/myproject 75 }}} 76 77 === Python Egg Cache === 78 79 Compressed python eggs like Genshi are normally extracted into a directory named `.python-eggs` in the users home directory. Since apache's home usually is not writable an alternate egg cache directory can be specified like this: 80 {{{ 81 PythonOption PYTHON_EGG_CACHE /var/trac/myprojects/egg-cache 82 }}} 83 84 or you can uncompress the Genshi egg to resolve problems extracting from it. 85 === Configuring Authentication === 86 87 Creating password files and configuring authentication works similar to the process for [wiki:TracCgi#AddingAuthentication CGI]: 88 {{{ 89 #!xml 90 <Location /projects/myproject/login> 27 91 AuthType Basic 28 92 AuthName "myproject" 29 AuthUserFile /var/trac/myproject/.ht access93 AuthUserFile /var/trac/myproject/.ht 30 94 Require valid-user 31 95 </Location> 32 96 }}} 33 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 34 176 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: 35 177 {{{ 178 36 179 <Location /projects/myproject> 37 180 ... … … 41 184 }}} 42 185 186 43 187 44 188 == Setting up multiple projects == 45 189 46 The Trac mod_python handler handler supports a configuration option similar to Subversion's `SvnParentPath`, called `TracEnvParentDir`: 47 {{{ 190 The Trac mod_python handler supports a configuration option similar to Subversion's `SvnParentPath`, called `TracEnvParentDir`: 191 {{{ 192 #!xml 48 193 <Location /projects> 49 194 SetHandler mod_python 195 50 196 PythonHandler trac.web.modpython_frontend 51 197 PythonOption TracEnvParentDir /var/trac … … 54 200 }}} 55 201 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.202 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. 57 203 58 204 If you don't want to have the subdirectory listing as your projects home page you can use a 59 205 {{{ 206 60 207 <LocationMatch "/.+/"> 61 208 }}} … … 65 212 You can also use the same authentication realm for all of the projects using a `<LocationMatch>` directive: 66 213 {{{ 67 <LocationMatch "/[^/]+/login"> 214 #!xml 215 <LocationMatch "/projects/[^/]+/login"> 68 216 AuthType Basic 69 217 AuthName "Trac" 70 AuthUserFile /var/trac/.ht access218 AuthUserFile /var/trac/.ht 71 219 Require valid-user 72 220 </LocationMatch> … … 79 227 80 228 {{{ 229 81 230 <VirtualHost * > 82 DocumentRoot /var/ trac/myproject231 DocumentRoot /var//myproject 83 232 ServerName trac.mycompany.com 84 < Directory/>233 < /> 85 234 SetHandler mod_python 235 86 236 PythonHandler trac.web.modpython_frontend 87 237 PythonOption TracEnv /var/trac/myproject 88 238 PythonOption TracUriRoot / 89 </ Directory>239 </> 90 240 <Location /login> 91 241 AuthType Basic 92 242 AuthName "MyCompany Trac Server" 93 AuthUserFile /var/trac/myproject/.ht users243 AuthUserFile /var/trac/myproject/.ht 94 244 Require valid-user 95 245 </Location> … … 97 247 }}} 98 248 249 250 251 252 253 254 255 256 257 99 258 == Troubleshooting == 100 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 101 281 === Form submission problems === 102 282 103 283 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. 104 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 105 299 === Using .htaccess === 106 300 … … 109 303 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. :) 110 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 111 332 === Win32 Issues === 112 113 If you run trac with mod_python (3.1.3 or 3.1.4) on Windows, 114 uploading attachments will '''not''' work. 115 This is a known problem which we can't solve cleanly at the Trac level. 116 117 However, there is a workaround for this at the mod_python level, 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] 119 to the (Lib/site-packages)/modpython/util.py file. 120 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'' 122 present in 3.1.4). 333 If you run trac with mod_python < 3.2 on Windows, uploading attachments will '''not''' work. This problem is resolved in mod_python 3.1.4 or later, so please upgrade mod_python to fix this. 334 123 335 124 336 === OS X issues === … … 126 338 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]. 127 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 128 410 ---- 129 See also TracGuide, TracInstall, TracCgi, TracFastCgi411 See also
