Changes between Version 1 and Version 2 of TracInstall


Ignore:
Timestamp:
24 May 2018, 12:41:09 (6 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracInstall

    v1 v2  
    3030As you must be using Python 2.5, 2.6 or 2.7, you already have the SQLite database bindings bundled with the standard distribution of Python: the `sqlite3` module.
    3131
    32 Optionally, you may install a newer version of [pypi:pysqlite pysqlite] than the one provided by the Python distribution. See [trac:PySqlite#ThePysqlite2bindings PySqlite] for details.
     32Optionally, you may install a newer version of [http://pypi.python.org/pypi/pysqlite pysqlite] than the one provided by the Python distribution. See [trac:PySqlite#ThePysqlite2bindings PySqlite] for details.
    3333
    3434==== For the PostgreSQL database #ForPostgreSQL
     
    112112The [TracAdmin trac-admin] command-line tool, used to create and maintain [TracEnvironment project environments], as well as the [TracStandalone tracd] standalone server are installed along with Trac. There are several methods for installing Trac.
    113113
     114It is assumed throughout this guide that you have elevated permissions as the `root` user, or by prefixing commands with `sudo`. The umask `0022` should be used for a typical installation on a Unix-based platform.
     115
    114116=== Using `easy_install`
    115117
    116 Trac can be installed from [https://pypi.python.org/pypi/Trac PyPI] or the Subversion repository using [pypi:setuptools setuptools].
     118Trac can be installed from [https://pypi.python.org/pypi/Trac PyPI] or the Subversion repository using [http://pypi.python.org/pypi/setuptools setuptools].
    117119
    118120A few command-line examples:
    119121
    120  - Install Trac 1.0:
     122 - Install the latest stable version of Trac:
    121123 {{{#!sh
    122 $ easy_install Trac==1.0
     124$ easy_install Trac
    123125}}}
    124126 - Install latest development version:
    125127 {{{#!sh
    126 $ easy_install Trac==dev
     128$ easy_install http://download.edgewall.org/trac/Trac-latest-dev.tar.gz
    127129}}}
    128130   Note that in this case you won't have the possibility to run a localized version of Trac;
    129131   either use a released version or install from source.
    130132
    131 More information can be found on the [trac:setuptools] page.
     133More information can be found on the [trac:wiki:setuptools setuptools] page.
    132134
    133135{{{#!div style="border: 1pt dotted; margin: 1em"
    134 **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].
    135137}}}
    136138
     
    230232
    231233{{{#!div style="border: 1pt dotted; margin: 1em"
    232 **Filesystem Warning:** When selecting the location of your environment, make sure that the filesystem on which the environment directory resides supports sub-second timestamps (i.e. **not** `ext2` or `ext3` on Linux), as the modification time of the `conf/trac.ini` file will be monitored to decide whether an environment restart is needed or not. A too coarse-grained timestamp resolution may result in inconsistencies in Trac < 1.0.2. The best advice is to opt for a platform with sub-second timestamp resolution, regardless of the Trac version.
     234**Filesystem Warning:** When selecting the location of your environment, make sure that the filesystem on which the environment directory resides supports sub-second timestamps (i.e. **not** `ext2` or `ext3` on Linux, or HFS+ on OSX), as the modification time of the `conf/trac.ini` file will be monitored to decide whether an environment restart is needed or not. A too coarse-grained timestamp resolution may result in inconsistencies in Trac < 1.0.2. The best advice is to opt for a platform with sub-second timestamp resolution, regardless of the Trac version.
    233235}}}
    234236
     
    246248== Deploying Trac
    247249
     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
    248268=== Running the Standalone Server
    249269
     
    256276{{{#!sh
    257277$ tracd -s --port 8000 /path/to/myproject
    258 }}}
    259 
    260 {{{#!div style="border: 1pt dotted; margin: 1em"
    261 **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.
    262 
    263 To 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`.
    264 {{{#!sh
    265 export PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1
    266 }}}
    267 
    268 Alternatively, the variable can be set in the shell before executing `tracd`:
    269 {{{#!sh
    270 $ PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1 tracd --port 8000 /path/to/myproject
    271 }}}
    272278}}}
    273279
     
    276282Trac provides various options for connecting to a "real" web server:
    277283 - [TracFastCgi FastCGI]
    278  - [wiki:TracModWSGI mod_wsgi]
    279  - [TracModPython mod_python]
     284 - [wiki:TracModWSGI Apache with mod_wsgi]
     285 - [TracModPython Apache with mod_python]
    280286 - //[TracCgi CGI]: should not be used, as it degrades performance//
    281287
     
    298304==== Mapping Static Resources
    299305
    300 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.
    301 
    302 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.
    303 
    304 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.
    305 
    306 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:
    307315[[TracAdminHelp(deploy)]]
    308316
    309 The target `<directory>` will then contain an `htdocs` directory with:
    310  - `site/` - a copy of the environment's directory `htdocs/`
    311  - `common/` - the static resources of Trac itself
    312  - `<plugins>/` - one directory for each resource directory managed by the plugins enabled for this environment
    313 
    314 ===== Example: Apache and `ScriptAlias` #ScriptAlias-example
    315 
    316 Assuming the deployment has been done this way:
    317 {{{#!sh
    318 $ trac-admin /var/trac/env deploy /path/to/shared/trac
    319 }}}
    320 
    321 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:
    322324{{{#!apache
    323325Alias /trac/chrome/common /path/to/trac/htdocs/common
    324326Alias /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
    325341
    326342<Directory "/path/to/www/trac/htdocs">
    327   Order allow,deny
    328   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>
    329352</Directory>
    330353}}}
    331354
    332 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:
    333356{{{#!apache
    334 <Location "/trac/chrome/common/">
     357<Location "/trac/chrome/common">
    335358  SetHandler None
    336359</Location>
    337360}}}
    338361
    339 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.
    340 
    341 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:
    342363{{{#!apache
    343364Alias /trac/chrome/site /path/to/projectenv/htdocs
    344365
    345366<Directory "/path/to/projectenv/htdocs">
    346   Order allow,deny
    347   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>
    348376</Directory>
    349377}}}
    350378
    351 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:
    352380{{{#!ini
    353381[trac]
     
    355383}}}
    356384
    357 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.
    358386
    359387Of 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: