Edgewall Software

Changes between Version 28 and Version 29 of TracFastCgi


Ignore:
Timestamp:
May 5, 2006, 6:58:56 AM (18 years ago)
Author:
jaboydjr@…
Comment:

Added detail about Apache modules, and optional method for setting env vars in trac.fcgi

Legend:

Unmodified
Added
Removed
Modified
  • TracFastCgi

    v28 v29  
    44
    55== Simple Apache configuration ==
     6
     7There are two FastCGI modules commonly available for Apache: `mod_fastcgi` and
     8`mod_fcgid`.  The `FastCgiIpcDir` and `FastCgiConfig` directives discussed
     9below are `mod_fastcgi` directives; the `DefaultInitEnv` is a `mod_fgcid`
     10directive.
     11
     12For `mod_fastcgi`, add the following to an appropriate Apache configuration
     13file:
    614{{{
    715# Enable fastcgi for .fcgi files
     
    1422LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
    1523}}}
    16 
    17 You can either setup the `TRAC_ENV` as an overall default:
     24Setting `FastCgiIpcDir` is optional if the default is suitable.
     25
     26Configure `ScriptAlias` or similar options as described in TracCgi, but
     27calling `trac.fcgi` instead of `trac.cgi`.
     28
     29You can set up the `TRAC_ENV` as an overall default:
    1830{{{
    1931FastCgiConfig -initial-env TRAC_ENV=/path/to/env/trac
     
    2537}}}
    2638
    27 Configure `ScriptAlias` or similar options as described in TracCgi, but calling `trac.fcgi` instead of `trac.cgi`.
    28 
    29 In Kubuntu, with libapache2_fcgid (version 1.07), the above did not work, with the error
    30 {{{
    31 Invalid command 'FastCgiConfig', perhaps mis-spelled or
    32 defined by a module not included in the server configuration.
    33 }}}
    34 when apache is started. The solution was to use
     39But neither of these will work for `mod_fcgid`.  A similar but partial
     40solution for `mod_fcgid` is:
    3541{{{
    3642DefaultInitEnv TRAC_ENV /path/to/env/trac/
    3743}}}
     44But this cannot be used in `Directory` or `Location` context, which makes it
     45difficult to support multiple projects.
     46
     47A better method which works for both of these modules (and for `lighttpd` and
     48CGI as well), because it involves no server configuration settings for
     49environment variables, is to set one of these variables in `trac.fcgi`, e.g.:
     50{{{
     51import os
     52os.environ['TRAC_ENV'] = "/path/to/projectenv"
     53}}}
     54or
     55{{{
     56import os
     57os.environ['TRAC_ENV_PARENT_DIR'] = "/path/to/project/parent/dir"
     58}}}
     59
     60Using this method, different projects can be supported by using different
     61`.cgi` scripts with different `ScriptAliases`, copying and appropriately
     62renaming `trac.fcgi` and adding the above code to create each such script.
    3863
    3964== Simple Lighttpd Configuration ==
     
    5883}}}
    5984
    60 Note that you will need to add a new entry to `fastcgi.server` for each separate Trac instance that you wish to run. Alternatively, you may use the `TRAC_ENV_PARENT_DIR` variable instead of `TRAC_ENV` as described  above.
    61 
    62 For using two projects with lighttpd add the following to your lighttpd.conf:
     85Note that you will need to add a new entry to `fastcgi.server` for each separate Trac instance that you wish to run. Alternatively, you may use the `TRAC_ENV_PARENT_DIR` variable instead of `TRAC_ENV` as described above,
     86and you may set one of the two in `trac.fcgi` instead of in `lighttpd.conf`
     87using `bin-environment` (as in the section above on Apache configuration).
     88
     89For using two projects with lighttpd add the following to your `lighttpd.conf`:
    6390{{{
    6491fastcgi.server = ("/first" =>
     
    82109                )
    83110}}}
    84 Note that field values are different.
     111Note that field values are different.  If you prefer setting the environment
     112variables in the `.fcgi` scripts, then copy/rename `trac.fcgi`, e.g., to
     113`first.fcgi` and `second.fcgi`, and reference them in the above settings.
     114Note that the above will result in different processes in any event, even
     115if both are running from the same `trac.fcgi` script.
    85116{{{
    86117#!html