Changes between Version 4 and Version 5 of TracInstall


Ignore:
Timestamp:
Sep 5, 2016 8:13:20 AM (9 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracInstall

    v4 v5  
    120120A few command-line examples:
    121121
    122  - Install Trac 1.0:
     122 - Install the latest stable version of Trac:
    123123 {{{#!sh
    124 $ easy_install Trac==1.0
     124$ easy_install Trac
    125125}}}
    126126 - Install latest development version:
    127127 {{{#!sh
    128 $ easy_install Trac==dev
     128$ easy_install http://download.edgewall.org/trac/Trac-latest-dev.tar.gz
    129129}}}
    130130   Note that in this case you won't have the possibility to run a localized version of Trac;
     
    134134
    135135{{{#!div style="border: 1pt dotted; margin: 1em"
    136 **Setuptools Warning:** If the version of your setuptools is in the range 5.4 through 5.6, the environment variable `PKG_RESOURCES_CACHE_ZIP_MANIFESTS` must be set in order to avoid significant performance degradation. More information may be found in the sections on [#RunningtheStandaloneServer Running The Standalone Server] and [#RunningTraconaWebServer Running Trac on a Web Server].
     136**Setuptools Warning:** If the version of your setuptools is in the range 5.4 through 5.6, the environment variable `PKG_RESOURCES_CACHE_ZIP_MANIFESTS` must be set in order to avoid significant performance degradation. More information may be found in [#DeployingTrac Deploying Trac].
    137137}}}
    138138
     
    248248== Deploying Trac
    249249
     250{{{#!div style="border: 1pt dotted; margin: 1em"
     251**Setuptools Warning:** If the version of your setuptools is in the range 5.4 through 5.6, the environment variable `PKG_RESOURCES_CACHE_ZIP_MANIFESTS` must be set in order to avoid significant performance degradation.
     252
     253If running `tracd`, the environment variable can be set system-wide or for just the user that runs the `tracd` process. There are several ways to accomplish this in addition to what is discussed here, and depending on the distribution of your OS.
     254
     255To be effective system-wide a shell script with the `export` statement may be added to `/etc/profile.d`. To be effective for a user session the `export` statement may be added to `~/.profile`.
     256{{{#!sh
     257export PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1
     258}}}
     259
     260Alternatively, the variable can be set in the shell before executing `tracd`:
     261{{{#!sh
     262$ PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1 tracd --port 8000 /path/to/myproject
     263}}}
     264
     265If running the Apache web server, !Ubuntu/Debian users should add the `export` statement to `/etc/apache2/envvars`. !RedHat/CentOS/Fedora should can add the `export` statement to `/etc/sysconfig/httpd`.
     266}}}
     267
    250268=== Running the Standalone Server
    251269
     
    258276{{{#!sh
    259277$ tracd -s --port 8000 /path/to/myproject
    260 }}}
    261 
    262 {{{#!div style="border: 1pt dotted; margin: 1em"
    263 **Setuptools Warning:** If the version of your setuptools is in the range 5.4 through 5.6, the environment variable `PKG_RESOURCES_CACHE_ZIP_MANIFESTS` must be set in order to avoid significant performance degradation. The environment variable can be set system-wide, or for just the user that runs the `tracd` process. There are several ways to accomplish this in addition to what is discussed here, and depending on the distribution of your OS.
    264 
    265 To be effective system-wide a shell script with the `export` statement may be added to `/etc/profile.d`.  !Ubuntu/Debian users can add the `export` statement to `/etc/apache2/envvars`. !RedHat/CentOS/Fedora users can add the `export` statement to `/etc/sysconfig/httpd`. To be effective for a user session the `export` statement may be added to `~/.profile`.
    266 {{{#!sh
    267 export PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1
    268 }}}
    269 
    270 Alternatively, the variable can be set in the shell before executing `tracd`:
    271 {{{#!sh
    272 $ PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1 tracd --port 8000 /path/to/myproject
    273 }}}
    274278}}}
    275279
     
    278282Trac provides various options for connecting to a "real" web server:
    279283 - [TracFastCgi FastCGI]
    280  - [wiki:TracModWSGI mod_wsgi]
    281  - [TracModPython mod_python]
     284 - [wiki:TracModWSGI Apache with mod_wsgi]
     285 - [TracModPython Apache with mod_python]
    282286 - //[TracCgi CGI]: should not be used, as it degrades performance//
    283287
     
    300304==== Mapping Static Resources
    301305
    302 Out of the box, Trac will pass static resources such as style sheets or images through itself. For anything but a tracd only based deployment, this is far from optimal as the web server could be set up to directly serve those static resources. For CGI setup, this is '''highly undesirable''' as it causes abysmal performance.
    303 
    304 Web servers such as [http://httpd.apache.org/ Apache] allow you to create "Aliases" to resources, giving them a virtual URL that doesn't necessarily reflect the layout of the servers file system. We also can map requests for static resources directly to the directory on the file system, avoiding processing these requests by Trac itself.
    305 
    306 There are two primary URL paths for static resources - `/chrome/common` and `/chrome/site`. Plugins can add their own resources, usually accessible by `/chrome/<plugin>` path, so its important to override only known paths and not try to make universal `/chrome` alias for everything.
    307 
    308 Note that in order to get those static resources on the filesystem, you need first to extract the relevant resources from Trac using the [TracAdmin trac-admin]` <environment> deploy` command:
     306Without additional configuration, Trac will handle requests for static resources such as stylesheets and images. For anything other than a TracStandalone deployment, this is not optimal as the web server can be set up to directly serve the static resources. For CGI setup, this is '''highly undesirable''' as it causes abysmal performance.
     307
     308Web servers such as [http://httpd.apache.org/ Apache] allow you to create //Aliases// to resources, giving them a virtual URL that doesn't necessarily reflect their location on the file system. We can map requests for static resources directly to directories on the file system, to avoid Trac processing the requests.
     309
     310There are two primary URL paths for static resources: `/chrome/common` and `/chrome/site`. Plugins can add their own resources, usually accessible at the `/chrome/<plugin>` path.
     311
     312A single `/chrome` alias can used if the static resources are extracted for all plugins. This means that the `deploy` command must be executed after installing or updating a plugin that provides static resources, or after modifying resources in the `$env/htdocs` directory. This is probably appropriate for most installations but may not be what you want if, for example, you wish to upload plugins through the //Plugins// administration page.
     313
     314The resources are extracted using the [TracAdmin trac-admin]` <environment> deploy` command:
    309315[[TracAdminHelp(deploy)]]
    310316
    311 The target `<directory>` will then contain an `htdocs` directory with:
    312  - `site/` - a copy of the environment's directory `htdocs/`
    313  - `common/` - the static resources of Trac itself
    314  - `<plugins>/` - one directory for each resource directory managed by the plugins enabled for this environment
    315 
    316 ===== Example: Apache and `ScriptAlias` #ScriptAlias-example
    317 
    318 Assuming the deployment has been done this way:
    319 {{{#!sh
    320 $ trac-admin /var/trac/env deploy /path/to/shared/trac
    321 }}}
    322 
    323 Add the following snippet to Apache configuration ''before'' the `ScriptAlias` or `WSGIScriptAlias` (which map all the other requests to the Trac application), changing paths to match your deployment:
     317The target `<directory>` will contain an `htdocs` directory with:
     318 - `common/` - the static resources of Trac
     319 - `site/` - a copy of the environment's `htdocs/` directory
     320 - `shared` - the static resources shared by multiple Trac environments, with a location defined by the `[inherit]` `htdocs_dir` option
     321 - `<plugin>/` - one directory for each resource directory provided by the plugins enabled for this environment
     322
     323The example that follows will create a single `/chrome` alias. If that isn't the correct approach for your installation you simply need to create more specific aliases:
    324324{{{#!apache
    325325Alias /trac/chrome/common /path/to/trac/htdocs/common
    326326Alias /trac/chrome/site /path/to/trac/htdocs/site
     327Alias /trac/chrome/shared /path/to/trac/htdocs/shared
     328Alias /trac/chrome/<plugin> /path/to/trac/htdocs/<plugin>
     329}}}
     330
     331===== Example: Apache and `ScriptAlias` #ScriptAlias-example
     332
     333Assuming the deployment has been done this way:
     334{{{#!sh
     335$ trac-admin /var/trac/env deploy /path/to/shared/trac
     336}}}
     337
     338Add the following snippet to Apache configuration, changing paths to match your deployment. The snippet must be placed ''before'' the `ScriptAlias` or `WSGIScriptAlias` directive, because those directives map all requests to the Trac application:
     339{{{#!apache
     340Alias /trac/chrome /path/to/trac/htdocs
    327341
    328342<Directory "/path/to/www/trac/htdocs">
    329   Order allow,deny
    330   Allow from all
     343  # For Apache 2.2
     344  <IfModule !mod_authz_core.c>
     345    Order allow,deny
     346    Allow from all
     347  </IfModule>
     348  # For Apache 2.4
     349  <IfModule mod_authz_core.c>
     350    Require all granted
     351  </IfModule>
    331352</Directory>
    332353}}}
    333354
    334 If using mod_python, you might want to add this too, otherwise the alias will be ignored:
     355If using mod_python, add this too, otherwise the alias will be ignored:
    335356{{{#!apache
    336 <Location "/trac/chrome/common/">
     357<Location "/trac/chrome/common">
    337358  SetHandler None
    338359</Location>
    339360}}}
    340361
    341 Note that we mapped `/trac` part of the URL to the `trac.*cgi` script, and the path `/trac/chrome/common` is the path you have to append to that location to intercept requests to the static resources.
    342 
    343 Similarly, if you have static resources in a project's `htdocs` directory (which is referenced by `/trac/chrome/site` URL in themes), you can configure Apache to serve those resources (again, put this ''before'' the `ScriptAlias` or `WSGIScriptAlias` for the .*cgi scripts, and adjust names and locations to match your installation):
     362Alternatively, if you wish to serve static resources directly from your project's `htdocs` directory rather than the location to which the files are extracted with the `deploy` command, you can configure Apache to serve those resources. Again, put this ''before'' the `ScriptAlias` or `WSGIScriptAlias` for the .*cgi scripts, and adjust names and locations to match your installation:
    344363{{{#!apache
    345364Alias /trac/chrome/site /path/to/projectenv/htdocs
    346365
    347366<Directory "/path/to/projectenv/htdocs">
    348   Order allow,deny
    349   Allow from all
     367  # For Apache 2.2
     368  <IfModule !mod_authz_core.c>
     369    Order allow,deny
     370    Allow from all
     371  </IfModule>
     372  # For Apache 2.4
     373  <IfModule mod_authz_core.c>
     374    Require all granted
     375  </IfModule>
    350376</Directory>
    351377}}}
    352378
    353 Alternatively to aliasing `/trac/chrome/common`, you can tell Trac to generate direct links for those static resources (and only those), using the [[TracIni#trac-section| [trac] htdocs_location]] configuration setting:
     379Another alternative to aliasing `/trac/chrome/common` is having Trac generate direct links for those static resources (and only those), using the [[TracIni#trac-section| [trac] htdocs_location]] configuration setting:
    354380{{{#!ini
    355381[trac]
     
    357383}}}
    358384
    359 Note that this makes it easy to have a dedicated domain serve those static resources, preferentially [http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain cookie-less].
     385Note that this makes it easy to have a dedicated domain serve those static resources, preferentially cookie-less.
    360386
    361387Of course, you still need to make the Trac `htdocs/common` directory available through the web server at the specified URL, for example by copying (or linking) the directory into the document root of the web server: