Edgewall Software

Changes between Version 168 and Version 169 of TracModPython


Ignore:
Timestamp:
May 9, 2015, 1:22:03 PM (9 years ago)
Author:
Jun Omae
Comment:

Use #!apache rather than #!xml for examples of Apache configuration

Legend:

Unmodified
Added
Removed
Modified
  • TracModPython

    v168 v169  
    1313
    1414If you just installed mod_python, you may have to add a line to load the module in the Apache configuration:
    15 {{{
     15{{{#!apache
    1616LoadModule python_module modules/mod_python.so
    1717}}}
     
    2020
    2121On Debian using apt-get:
    22 {{{
     22{{{#!sh
    2323apt-get install libapache2-mod-python libapache2-mod-python-doc
    2424}}}
    2525
    2626Still on Debian, after you have installed mod_python, you must enable the modules in apache2, equivalent to the above Load Module directive:
    27 {{{
     27{{{#!sh
    2828a2enmod python
    2929}}}
    3030
    3131On Fedora use, using yum:
    32 {{{
     32{{{#!sh
    3333yum install mod_python
    3434}}}
    3535
    3636You can test your mod_python installation by adding the following to your httpd.conf. You should remove this when you are done testing for security reasons. Note: mod_python.testhandler is only available in mod_python 3.2+.
    37 {{{#!xml
     37{{{#!apache
    3838<Location /mpinfo>
    3939   SetHandler mod_python
     
    4646
    4747A simple setup of Trac on mod_python looks like this:
    48 {{{#!xml
     48{{{#!apache
    4949<Location /projects/myproject>
    5050   SetHandler mod_python
     
    6161
    6262The options available are:
    63 {{{
     63{{{#!apache
    6464# For a single project
    6565PythonOption TracEnv /var/trac/myproject
     
    8484
    8585Compressed 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 writeable, an alternate egg cache directory can be specified like this:
    86 {{{
     86{{{#!apache
    8787PythonOption PYTHON_EGG_CACHE /var/trac/myprojects/egg-cache
    8888}}}
     
    100100If the Egg Cache isn't writeable by your Web server, you'll either have to change the permissions, or point Python to a location where Apache can write. This can manifest itself as a `500 internal server error` and/or a complaint in the syslog.
    101101
    102 {{{#!xml
     102{{{#!apache
    103103<Location /projects/myproject>
    104104  ...
     
    111111
    112112If the Trac installation isn't installed in your Python path, you will have to tell Apache where to find the Trac mod_python handler  using the `PythonPath` directive:
    113 {{{#!xml
     113{{{#!apache
    114114<Location /projects/myproject>
    115115  ...
     
    124124
    125125The Trac mod_python handler supports a configuration option similar to Subversion's `SvnParentPath`, called `TracEnvParentDir`:
    126 {{{#!xml
     126{{{#!apache
    127127<Location /projects>
    128128  SetHandler mod_python
     
    137137
    138138If you don't want to have the subdirectory listing as your projects home page you can use a
    139 {{{#!xml
     139{{{#!apache
    140140<LocationMatch "/.+/">
    141141}}}
     
    144144
    145145You can also use the same authentication realm for all of the projects using a `<LocationMatch>` directive:
    146 {{{#!xml
     146{{{#!apache
    147147<LocationMatch "/projects/[^/]+/login">
    148148  AuthType Basic
     
    158158`http://trac.mycompany.com`:
    159159
    160 {{{#!xml
    161 <VirtualHost * >
     160{{{#!apache
     161<VirtualHost *>
    162162    DocumentRoot /var/www/myproject
    163163    ServerName trac.mycompany.com
     
    190190
    191191If you get server error pages, you can either check the Apache error log, or enable the `PythonDebug` option:
    192 {{{#!xml
     192{{{#!apache
    193193<Location /projects/myproject>
    194194  ...
     
    203203If you've used `<Location />` directive, it will override any other directives, as well as `<Location /login>`.
    204204The workaround is to use negation expression as follows (for multi project setups):
    205 {{{#!xml
     205{{{#!apache
    206206#this one for other pages
    207207<Location ~ "/*(?!login)">
     
    210210   PythonOption TracEnvParentDir /projects
    211211   PythonOption TracUriRoot /
    212 
    213 </Location>
     212</Location>
     213
    214214#this one for login page
    215215<Location ~ "/[^/]+/login">
     
    262262
    263263This also works out-of-box, with following trivial config:
    264 {{{#!xml
     264{{{#!apache
    265265SetHandler mod_python
    266266PythonInterpreter main_interpreter
     
    281281If you are using the .htaccess method you may have additional problems if your Trac directory is inheriting .htaccess directives from another. This may also help to add to your .htaccess file:
    282282
    283 {{{#!xml
     283{{{#!apache
    284284<IfModule mod_rewrite.c>
    285285  RewriteEngine Off
     
    330330
    331331You 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:
    332 {{{
     332{{{#!apache
    333333PythonInterpreter main_interpreter
    334334}}}
     
    339339
    340340If the formatting of the Trac pages look weird, chances are that the style sheets governing the page layout are not handled properly by the web server. Try adding the following lines to your Apache configuration:
    341 {{{#!xml
     341{{{#!apache
    342342Alias /myproject/css "/usr/share/trac/htdocs/css"
    343343<Location /myproject/css>
     
    353353
    354354If you want to run Trac fully under https you might find that it tries to redirect to plain http. In this case just add the following line to your Apache configuration:
    355 {{{#!xml
    356 <VirtualHost * >
     355{{{#!apache
     356<VirtualHost *>
    357357    DocumentRoot /var/www/myproject
    358358    ServerName trac.mycompany.com