Changes between Version 20 and Version 21 of TracCgi
- Timestamp:
- Aug 26, 2006, 11:10:10 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracCgi
v20 v21 1 1 = Installing Trac as CGI = 2 2 3 To install Trac as a CGI script, you need to make the `trac.cgi` executable as a CGI by your web server. Please note that doing this is quite a bit slower than using the TracModPython method. If you're using [http://httpd.apache.org/ Apache HTTPD], there are a couple ways to do that: 3 To install Trac as a CGI script, you need to make the `trac.cgi` executable as a CGI by your web server. 4 5 ''Please note that using Trac via CGI is significantly slower than any other deployment method, such as [TracModPython mod_python] or [TracFastCgi FastCGI].'' 6 7 If you're using [http://httpd.apache.org/ Apache HTTPD], there are a couple ways to do that: 4 8 5 9 1. Use a `ScriptAlias` to map a URL to the `trac.cgi` script … … 13 17 }}} 14 18 15 If you're using Trac with a single project set its location: 19 ''Note that this directive requires the `mod_alias` module to be installed and enabled.'' 20 21 If you're using Trac with a single project you need to set its location using the `TRAC_ENV` environment variable: 16 22 {{{ 17 23 <Location "/trac"> … … 20 26 }}} 21 27 22 Or to use multiple projects from a parent directory:28 Or to use multiple projects you can specify their common parent directory using the `TRAC_ENV_PARENT_DIR` variable: 23 29 {{{ 24 30 <Location "/trac"> … … 27 33 }}} 28 34 29 ''Note: Make sure that the modules mod_alias and mod_env modules are available and enabled in your Apache configuration, otherwise Apache will complain about the above snippet.'' 30 31 ''Note: If you are using the [http://httpd.apache.org/docs/suexec.html Apache suEXEC] feature see ApacheSuexec.'' 32 33 ''Note: You may need to edit the shebang line in the share/trac/cgi-bin/trac.cgi file in your Python installation to point to your real Python installation path. On a Windows system you may need to configure Windows to know how to execute a .cgi file (Explorer -> Tools -> Folder Options -> File Types -> CGI). 34 35 Alternately, these variables can be set in `trac.cgi` and thus not require 36 Apache `SetEnv` directives at all, e.g.: 37 {{{ 38 import os 39 os.environ['TRAC_ENV'] = "/path/to/projectenv" 40 }}} 41 or 42 {{{ 43 import os 44 os.environ['TRAC_ENV_PARENT_DIR'] = "/path/to/project/parent/dir" 45 }}} 46 Using this method, different projects can be supported by using different 47 `.cgi` scripts with different `ScriptAliases`, copying and appropriately 48 renaming `trac.cgi` and adding the above code to create each such script. 35 ''Note that the `SetEnv` directive requires the `mod_env` module to be installed and enable.'' 49 36 50 37 This will make Trac available at `http://yourhost.example.org/trac`. 51 38 39 If you are using the [http://httpd.apache.org/docs/suexec.html Apache suEXEC] feature please see [http://trac.edgewall.org/wiki/ApacheSuexec]. 40 41 On some systems, you ''may'' need to edit the shebang line in the `trac.cgi` file to point to your real Python installation path. On a Windows system you may need to configure Windows to know how to execute a .cgi file (Explorer -> Tools -> Folder Options -> File Types -> CGI). 42 52 43 == Mapping Static Resources == 53 44 54 Out of the box, Trac will serve static resources such as style sheets or images itself. For a CGI setup, though, this is highly undesirable, because it results in the CGI script being invoked for documents that could be m ore efficiently served by the web server.45 Out of the box, Trac will serve static resources such as style sheets or images itself. For a CGI setup, though, this is highly undesirable, because it results in the CGI script being invoked for documents that could be much more efficiently served by the web server directly. 55 46 56 47 Web servers such as [http://httpd.apache.org/ Apache HTTPD] allow you to create “Aliases” to resources, thereby giving them a virtual URL that doesn't necessarily bear any resemblance to the layout of the servers file system. We already used this capability above when defining a `ScriptAlias` for the CGI script, and we'll use it now to map requests to the static resources to the directory on the file system that contains them, thereby bypassing the processing of such requests by the CGI script.