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. |
11 | | |
12 | | == Simple configuration == |
| 7 | These instructions are for Apache 2. If you are using Apache 1.3, you may have some luck with [trac:wiki:TracModPython2.7 TracModPython2.7], but that is a deprecated setup. |
| 8 | |
| 9 | [[PageOutline(2-3,Overview,inline)]] |
| 10 | |
| 11 | == Simple configuration: single project == #Simpleconfiguration |
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 |
| 58 | 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. |
| 59 | |
| 60 | The options available are: |
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> |
91 | | AuthType Basic |
92 | | AuthName "myproject" |
93 | | AuthUserFile /var/trac/myproject/.htpasswd |
94 | | Require valid-user |
95 | | </Location> |
96 | | }}} |
97 | | |
98 | | Configuration for mod_ldap authentication in Apache is a bit tricky (httpd 2.2.x and OpenLDAP: slapd 2.3.19) |
99 | | |
100 | | 1. You need to load the following modules in Apache httpd.conf |
101 | | {{{ |
102 | | LoadModule ldap_module modules/mod_ldap.so |
103 | | LoadModule authnz_ldap_module modules/mod_authnz_ldap.so |
104 | | }}} |
105 | | |
106 | | 2. Your httpd.conf also needs to look something like: |
107 | | |
108 | | {{{ |
109 | | #!xml |
110 | | <Location /trac/> |
111 | | SetHandler mod_python |
112 | | PythonInterpreter main_interpreter |
113 | | PythonHandler trac.web.modpython_frontend |
114 | | PythonOption TracEnv /home/trac/ |
115 | | PythonOption TracUriRoot /trac/ |
116 | | Order deny,allow |
117 | | Deny from all |
118 | | Allow from 192.168.11.0/24 |
119 | | AuthType Basic |
120 | | AuthName "Trac" |
121 | | AuthBasicProvider "ldap" |
122 | | AuthLDAPURL "ldap://127.0.0.1/dc=example,dc=co,dc=ke?uid?sub?(objectClass=inetOrgPerson)" |
123 | | authzldapauthoritative Off |
124 | | require valid-user |
125 | | </Location> |
126 | | }}} |
127 | | |
128 | | Or the LDAP interface to a Microsoft Active Directory: |
129 | | |
130 | | {{{ |
131 | | #!xml |
132 | | <Location /trac/> |
133 | | SetHandler mod_python |
134 | | PythonInterpreter main_interpreter |
135 | | PythonHandler trac.web.modpython_frontend |
136 | | PythonOption TracEnv /home/trac/ |
137 | | PythonOption TracUriRoot /trac/ |
138 | | Order deny,allow |
139 | | Deny from all |
140 | | Allow from 192.168.11.0/24 |
141 | | AuthType Basic |
142 | | AuthName "Trac" |
143 | | AuthBasicProvider "ldap" |
144 | | AuthLDAPURL "ldap://adserver.company.com:3268/DC=company,DC=com?sAMAccountName?sub?(objectClass=user)" |
145 | | AuthLDAPBindDN ldap-auth-user@company.com |
146 | | AuthLDAPBindPassword "the_password" |
147 | | authzldapauthoritative Off |
148 | | # require valid-user |
149 | | require ldap-group CN=Trac Users,CN=Users,DC=company,DC=com |
150 | | </Location> |
151 | | }}} |
152 | | |
153 | | Note 1: This is the case where the LDAP search will get around the multiple OUs, conecting to Global Catalog Server portion of AD (Notice the port is 3268, not the normal LDAP 389). The GCS is basically a "flattened" tree which allows searching for a user without knowing to which OU they belong. |
154 | | |
155 | | Note 2: Active Directory requires an authenticating user/password to access records (AuthLDAPBindDN and AuthLDAPBindPassword). |
156 | | |
157 | | Note 3: The directive "require ldap-group ..." specifies an AD group whose members are allowed access. |
158 | | |
159 | | |
160 | | === Setting the Python Egg Cache === |
| 89 | |
| 90 | === Configuring Authentication |
| 91 | |
| 92 | See corresponding section in the [wiki:TracModWSGI#ConfiguringAuthentication] page. |
| 93 | |
| 94 | == Advanced Configuration |
| 95 | |
| 96 | === Setting the Python Egg Cache |
| 206 | === Login Not Working |
| 207 | |
| 208 | If you've used `<Location />` directive, it will override any other directives, as well as `<Location /login>`. |
| 209 | The workaround is to use negation expression as follows (for multi project setups): |
| 210 | {{{ |
| 211 | #!xml |
| 212 | #this one for other pages |
| 213 | <Location ~ "/*(?!login)"> |
| 214 | SetHandler mod_python |
| 215 | PythonHandler trac.web.modpython_frontend |
| 216 | PythonOption TracEnvParentDir /projects |
| 217 | PythonOption TracUriRoot / |
| 218 | |
| 219 | </Location> |
| 220 | #this one for login page |
| 221 | <Location ~ "/[^/]+/login"> |
| 222 | SetHandler mod_python |
| 223 | PythonHandler trac.web.modpython_frontend |
| 224 | PythonOption TracEnvParentDir /projects |
| 225 | PythonOption TracUriRoot / |
| 226 | |
| 227 | #remove these if you don't want to force SSL |
| 228 | RewriteEngine On |
| 229 | RewriteCond %{HTTPS} off |
| 230 | RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} |
| 231 | |
| 232 | AuthType Basic |
| 233 | AuthName "Trac" |
| 234 | AuthUserFile /projects/.htpasswd |
| 235 | Require valid-user |
| 236 | </Location> |
| 237 | }}} |
| 238 | |
274 | | In Python 2.4, some version of Expat (an XML parser library written in C) is used, |
275 | | and if Apache is using another version, this results in segmentation faults. |
276 | | As Trac 0.11 is using Genshi, which will indirectly use Expat, that problem |
277 | | can now hit you even if everything was working fine before with Trac 0.10. |
278 | | |
279 | | See Graham Dumpleton's detailed [http://www.dscpl.com.au/wiki/ModPython/Articles/ExpatCausingApacheCrash explanation and workarounds] for the issue. |
280 | | |
281 | | === Form submission problems === |
| 242 | In Python 2.4, some version of [http://expat.sourceforge.net/ Expat] (an XML parser library written in C) is used and if Apache is using another version, this results in segmentation faults. |
| 243 | As Trac 0.11 is using Genshi, which will indirectly use Expat, that problem can now hit you even if everything was working fine before with Trac 0.10. This problem has not been reported for Python 2.5+, so best to upgrade. |
| 244 | |
| 245 | === Form submission problems |
285 | | === Problem with virtual host configuration === |
286 | | |
287 | | If the <Location /> directive is used, setting the `DocumentRoot` may result in a ''403 (Forbidden)'' error. Either remove the `DocumentRoot` directive, or make sure that accessing the directory it points is allowed (in a corresponding `<Directory>` block). |
288 | | |
289 | | Using <Location /> together with `SetHandler` resulted in having everything handled by mod_python, which leads to not being able download any CSS or images/icons. I used <Location /trac> `SetHandler None` </Location> to circumvent the problem, though I do not know if this is the most elegant solution. |
290 | | |
291 | | === Problem with zipped egg === |
| 249 | === Problem with virtual host configuration |
| 250 | |
| 251 | If the <Location /> directive is used, setting the `DocumentRoot` may result in a ''403 (Forbidden)'' error. Either remove the `DocumentRoot` directive, or make sure that accessing the directory it points is allowed, in a corresponding `<Directory>` block. |
| 252 | |
| 253 | Using <Location /> together with `SetHandler` resulted in having everything handled by mod_python, which leads to not being able to download any CSS or images/icons. Use <Location /trac> `SetHandler None` </Location> to circumvent the problem, though this may not be the most elegant solution. |
| 254 | |
| 255 | === Problem with zipped egg |
349 | | See also [http://subversion.tigris.org/faq.html#reposperms] |
350 | | |
351 | | === FreeBSD issues === |
352 | | Pay attention to the version of the installed mod_python and sqlite packages. Ports have both the new and old ones, but earlier versions of pysqlite and mod_python won't integrate as the former requires threaded support in python, and the latter requires a threadless install. |
353 | | |
354 | | If you compiled and installed apache2, apache wouldn´t support threads (cause it doesn´t work very well on FreeBSD). You could force thread support when running ./configure for apache, using --enable-threads, but this isn´t recommendable. |
355 | | The best option [http://modpython.org/pipermail/mod_python/2006-September/021983.html seems to be] adding to /usr/local/apache2/bin/ennvars the line |
| 313 | See also [http://subversion.apache.org/faq.html#reposperms How do I set repository permissions correctly?] |
| 314 | |
| 315 | ==== FreeBSD issues |
| 316 | |
| 317 | The FreeBSD ports have both the new and old versions of mod_python and SQLite, but earlier versions of pysqlite and mod_python won't integrate as the former requires threaded support in Python, and the latter requires a threadless install. |
| 318 | |
| 319 | If you compiled and installed apache2, threads are not automatically supported on FreeBSD. You could force thread support when running `./configure` for Apache, using `--enable-threads`, but this isn´t recommended. |
| 320 | The best option [http://modpython.org/pipermail/mod_python/2006-September/021983.html seems to be] adding to /usr/local/apache2/bin/ennvars the line: |
361 | | === Subversion issues === |
362 | | |
363 | | If you get the following Trac Error `Unsupported version control system "svn"` only under mod_python, though it works well on the command-line and even with TracStandalone, chances are that you forgot to add the path to the Python bindings with the [TracModPython#ConfiguringPythonPath PythonPath] directive. (The better way is to add a link to the bindings in the Python `site-packages` directory, or create a `.pth` file in that directory.) |
364 | | |
365 | | If this is not the case, it's possible that you're using Subversion libraries that are binary incompatible with the apache ones (an incompatibility of the `apr` libraries is usually the cause). In that case, you also won't be able to use the svn modules for Apache (`mod_dav_svn`). |
366 | | |
367 | | You also need a recent version of `mod_python` in order to avoid a runtime error ({{{argument number 2: a 'apr_pool_t *' is expected}}}) due to the default usage of multiple sub-interpreters. 3.2.8 ''should'' work, though it's probably better to use the workaround described in [trac:#3371 #3371], in order to force the use of the main interpreter: |
| 326 | ==== Fedora 7 Issues |
| 327 | |
| 328 | Make sure you install the 'python-sqlite2' package as it seems to be required for TracModPython but not for tracd. |
| 329 | |
| 330 | === Subversion issues |
| 331 | |
| 332 | If you get the following Trac error `Unsupported version control system "svn"` only under mod_python, though it works well on the command-line and even with TracStandalone, chances are that you forgot to add the path to the Python bindings with the [TracModPython#ConfiguringPythonPath PythonPath] directive. The better way is to add a link to the bindings in the Python `site-packages` directory, or create a `.pth` file in that directory. |
| 333 | |
| 334 | If this is not the case, it's possible that you're using Subversion libraries that are binary incompatible with the Apache ones and an incompatibility of the `apr` libraries is usually the cause. In that case, you also won't be able to use the svn modules for Apache (`mod_dav_svn`). |
| 335 | |
| 336 | You also need a recent version of `mod_python` in order to avoid a runtime error ({{{argument number 2: a 'apr_pool_t *' is expected}}}) due to the default usage of multiple sub-interpreters. Version 3.2.8 ''should'' work, though it's probably better to use the workaround described in [trac:#3371 #3371], in order to force the use of the main interpreter: |
401 | | === Fedora 7 Issues === |
402 | | Make sure you install the 'python-sqlite2' package as it seems to be required for TracModPython but not for tracd |
403 | | |
404 | | |
405 | | === Segmentation fault with php5-mhash or other php5 modules === |
406 | | You may encounter segfaults (reported on debian etch) if php5-mhash module is installed. Try to remove it to see if this solves the problem. See debian bug report [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411487] |
407 | | |
408 | | Some people also have troubles when using php5 compiled with its own 3rd party libraries instead of system libraries. Check here [http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault] |
| 371 | === Segmentation fault with php5-mhash or other php5 modules |
| 372 | |
| 373 | You may encounter segfaults (reported on Debian etch) if php5-mhash module is installed. Try to remove it to see if this solves the problem. See [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411487 Debian bug report]. |
| 374 | |
| 375 | Some people also have troubles when using php5 compiled with its own 3rd party libraries instead of system libraries. Check [http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault Django segmentation fault]. |