Changes between Version 7 and Version 8 of Trac Install


Ignore:
Timestamp:
Oct 25, 2020, 10:52:22 PM (3 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Trac Install

    v7 v8  
    1 = Trac Installation Guide for 1.1
     1= Trac Installation Guide for 1.2
    22[[TracGuideToc]]
    33
    4 Trac is written in the Python programming language and needs a database, [http://sqlite.org/ SQLite], [http://www.postgresql.org/ PostgreSQL], or [http://mysql.com/ MySQL]. For HTML rendering, Trac uses the [http://genshi.edgewall.org Genshi] templating system.
     4Trac is written in the Python programming language and needs a database, [https://sqlite.org/ SQLite], [https://www.postgresql.org/ PostgreSQL], or [https://www.mysql.com/ MySQL]. For HTML rendering, Trac uses the [https://genshi.edgewall.org/ Genshi] templating system.
    55
    66Trac can also be localized, and there is probably a translation available in your language. If you want to use the Trac interface in other languages, then make sure you have installed the optional package [#OtherPythonPackages Babel]. Pay attention to the extra steps for localization support in the [#InstallingTrac Installing Trac] section below. Lacking Babel, you will only get the default English version.
     
    1616To install Trac, the following software packages must be installed:
    1717
    18  * [http://www.python.org/ Python], version >= 2.6 and < 3.0
     18 * [https://www.python.org/ Python], version >= 2.6 and < 3.0
    1919   (note that we dropped the support for Python 2.5 in this release)
    20  * [http://pypi.python.org/pypi/setuptools setuptools], version >= 0.6
    21  * [http://genshi.edgewall.org/wiki/Download Genshi], version >= 0.6
     20 * [https://pypi.org/project/setuptools setuptools], version >= 0.6
     21 * [https://pypi.org/project/Genshi Genshi], version >= 0.6
    2222
    2323You also need a database system and the corresponding python bindings. The database can be either SQLite, PostgreSQL or MySQL.
     
    2727As you must be using Python 2.6 or 2.7, you already have the SQLite database bindings bundled with the standard distribution of Python (the `sqlite3` module).
    2828
    29 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.
     29Optionally, you may install a newer version of [https://pypi.org/project/pysqlite pysqlite] than the one provided by the Python distribution. See [trac:PySqlite#ThePysqlite2bindings PySqlite] for details.
    3030
    3131==== For the PostgreSQL database #ForPostgreSQL
    3232
    3333You need to install the database and its Python bindings:
    34  * [http://www.postgresql.org/ PostgreSQL], version 8.0 or later
    35  * [http://pypi.python.org/pypi/psycopg2 psycopg2], version 2.0 or later
     34 * [https://www.postgresql.org/ PostgreSQL], version 8.0 or later
     35 * [https://pypi.org/project/psycopg2 psycopg2], version 2.0 or later
    3636
    3737See [trac:DatabaseBackend#Postgresql DatabaseBackend] for details.
     
    4141Trac works well with MySQL, provided you follow the guidelines:
    4242
    43  * [http://mysql.com/ MySQL], version 5.0 or later
    44  * [http://sf.net/projects/mysql-python MySQLdb], version 1.2.2 or later
     43 * [https://www.mysql.com/ MySQL], version 5.0 or later
     44 * [https://sf.net/projects/mysql-python MySQLdb], version 1.2.2 or later
    4545
    4646Given the caveats and known issues surrounding MySQL, read carefully the [trac:MySqlDb] page before creating the database.
     
    5050==== Subversion
    5151
    52 [http://subversion.apache.org/ Subversion], 1.6.x or later and the '''''corresponding''''' Python bindings.
    53 
    54 There are [http://subversion.apache.org/packages.html pre-compiled SWIG bindings] available for various platforms. (Good luck finding precompiled SWIG bindings for any Windows package at that listing. [trac:TracSubversion] points you to [http://alagazam.net Alagazam], which works for me under Python 2.6.)
     52[https://subversion.apache.org/ Subversion], 1.6.x or later and the '''''corresponding''''' Python bindings.
     53
     54There are [https://subversion.apache.org/packages.html pre-compiled SWIG bindings] available for various platforms. (Good luck finding precompiled SWIG bindings for any Windows package at that listing. [trac:TracSubversion] points you to [https://alagazam.net Alagazam], which works for me under Python 2.6.)
    5555
    5656For troubleshooting information, see the [trac:TracSubversion#Troubleshooting TracSubversion] page.
     
    6464==== Git
    6565
    66 [http://git-scm.com/ Git] 1.5.6 or later is supported. More information is available on the [trac:TracGit] page.
     66[https://git-scm.com/ Git] 1.5.6 or later is supported. More information is available on the [trac:TracGit] page.
    6767
    6868==== Other Version Control Systems
     
    7474
    7575Alternatively you can configure Trac to run in any of the following environments:
    76  * [http://httpd.apache.org/ Apache] with
    77    - [https://github.com/GrahamDumpleton/mod_wsgi mod_wsgi], see [wiki:TracModWSGI] and
    78      [http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac ModWSGI IntegrationWithTrac].
    79    - [http://modpython.org/ mod_python 3.5.0], see TracModPython
    80  * a [http://www.fastcgi.com/ FastCGI]-capable web server (see TracFastCgi)
    81  * an [http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html AJP]-capable web
     76 * [https://httpd.apache.org/ Apache] with
     77  * [https://github.com/GrahamDumpleton/mod_wsgi mod_wsgi], see [wiki:TracModWSGI] and [https://code.google.com/p/modwsgi/wiki/IntegrationWithTrac ModWSGI IntegrationWithTrac].
     78  * [http://modpython.org/ mod_python 3.5.0], see TracModPython
     79 * a [https://fastcgi-archives.github.io/ FastCGI]-capable web server (see TracFastCgi)
     80 * an [https://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html AJP]-capable web
    8281   server (see [trac:TracOnWindowsIisAjp TracOnWindowsIisAjp])
    8382 * Microsoft IIS with FastCGI and a FastCGI-to-WSGI gateway (see [trac:CookBook/Installation/TracOnWindowsIisWfastcgi IIS with FastCGI])
     
    108107The [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.
    109108
     109It is assumed throughout this guide that you have elevated permissions as the `root` user or by prefixing commands with `sudo`. The umask `0002` should be used for a typical installation on a Unix-based platform.
     110
    110111=== Using `easy_install`
    111 Trac can be installed from PyPI or the Subversion repository using [http://pypi.python.org/pypi/setuptools setuptools].
     112Trac can be installed from PyPI or the Subversion repository using [https://pypi.org/project/setuptools setuptools].
    112113
    113114A few examples:
    114115
    115  - Install Trac 1.0:
    116    {{{#!sh
    117    easy_install Trac==1.0
    118    }}}
     116 - Install the latest stable version of Trac:
     117 {{{#!sh
     118$ easy_install Trac
     119}}}
    119120 - Install latest development version:
    120    {{{#!sh
    121    easy_install Trac==dev
    122    }}}
     121 {{{#!sh
     122$ easy_install https://download.edgewall.org/trac/Trac-latest-dev.tar.gz
     123}}}
    123124   Note that in this case you won't have the possibility to run a localized version of Trac;
    124125   either use a released version or install from source
    125126
    126 More information can be found on the [trac:setuptools] page.
    127 
    128 {{{#!div style="border: 1pt dotted; margin: 1em"
    129 **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].
     127More information can be found on the [trac:wiki:setuptools setuptools] page.
     128
     129{{{#!div style="border: 1pt dotted; margin: 1em"
     130**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].
    130131}}}
    131132
     
    136137Assuming you want to have your entire pip installation in `/opt/user/trac`
    137138
    138  -
    139139 {{{#!sh
    140 pip install trac psycopg2
     140$ pip install trac psycopg2
    141141}}}
    142142or
    143  -
    144143 {{{#!sh
    145 pip install trac mysql-python
     144$ pip install trac mysql-python
    146145}}}
    147146
     
    184183To install Trac to a custom location, or find out about other advanced installation options, run:
    185184{{{#!sh
    186 easy_install --help
    187 }}}
    188 
    189 Also see [http://docs.python.org/2/install/index.html Installing Python Modules] for detailed information.
     185$ easy_install --help
     186}}}
     187
     188Also see [https://docs.python.org/2/install/index.html Installing Python Modules] for detailed information.
    190189
    191190Specifically, you might be interested in:
    192191{{{#!sh
    193 easy_install --prefix=/path/to/installdir
     192$ easy_install --prefix=/path/to/installdir
    194193}}}
    195194or, if installing Trac on a Mac OS X system:
    196195{{{#!sh
    197 easy_install --prefix=/usr/local --install-dir=/Library/Python/2.6/site-packages
     196$ easy_install --prefix=/usr/local --install-dir=/Library/Python/2.6/site-packages
    198197}}}
    199198
     
    213212}}}
    214213
    215 [TracAdmin trac-admin] will prompt you for the information it needs to create the environment: the name of the project and the [TracEnvironment#DatabaseConnectionStrings database connection string]. If you're not sure what to specify for any of these options, just press `<Enter>` to use the default value.
     214You will be prompted for the information needed to create the environment: the name of the project and the [TracEnvironment#DatabaseConnectionStrings database connection string]. If you're not sure what to specify for any of these options, just press `<Enter>` to use the default value.
    216215
    217216Using the default database connection string will always work as long as you have SQLite installed. For the other [trac:DatabaseBackend database backends] you should plan ahead and already have a database ready to use at this point.
     
    236235== Deploying Trac
    237236
     237{{{#!div style="border: 1pt dotted; margin: 1em"
     238**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.
     239
     240If 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.
     241
     242To 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`.
     243{{{#!sh
     244export PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1
     245}}}
     246
     247Alternatively, the variable can be set in the shell before executing `tracd`:
     248{{{#!sh
     249$ PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1 tracd --port 8000 /path/to/myproject
     250}}}
     251
     252If 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`.
     253}}}
     254
    238255=== Running the Standalone Server
    239256
     
    246263{{{#!sh
    247264$ tracd -s --port 8000 /path/to/myproject
    248 }}}
    249 
    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. 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.
    252 
    253 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`.
    254 {{{#!sh
    255 export PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1
    256 }}}
    257 
    258 Alternatively, the variable can be set in the shell before executing `tracd`:
    259 {{{#!sh
    260 $ PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1 tracd --port 8000 /path/to/myproject
    261 }}}
    262265}}}
    263266
     
    266269Trac provides various options for connecting to a "real" web server:
    267270 - [TracFastCgi FastCGI]
    268  - [wiki:TracModWSGI mod_wsgi]
    269  - [TracModPython mod_python]
    270  - //[TracCgi CGI] (should not be used, as the performance is far from optimal)//
    271 
    272 Trac also supports [trac:TracOnWindowsIisAjp AJP] which may be your choice if you want to connect to IIS. Other deployment scenarios are possible: [trac:TracNginxRecipe nginx], [http://projects.unbit.it/uwsgi/wiki/Example#Traconapacheinasub-uri uwsgi], [trac:TracOnWindowsIisIsapi Isapi-wsgi] etc.
     271 - [wiki:TracModWSGI Apache with mod_wsgi]
     272 - [TracModPython Apache with mod_python]
     273 - [TracCgi CGI] //(should not be used, as the performance is far from optimal)//
     274
     275Trac also supports [trac:TracOnWindowsIisAjp AJP] which may be your choice if you want to connect to IIS. Other deployment scenarios are possible: [trac:TracNginxRecipe nginx], [https://uwsgi-docs.readthedocs.io/en/latest/#Traconapacheinasub-uri uwsgi], [trac:TracOnWindowsIisIsapi Isapi-wsgi] etc.
    273276
    274277==== Generating the Trac cgi-bin directory #cgi-bin
    275278
    276 In order for Trac to function properly with FastCGI you need to have a `trac.fcgi` file and for mod_wsgi a `trac.wsgi` file. These are Python scripts which load the appropriate Python code. They can be generated using the `deploy` option of [TracAdmin trac-admin].
    277 
    278 There is, however, a bit of a chicken-and-egg problem. The [TracAdmin trac-admin] command requires an existing environment to function, but complains if the deploy directory already exists. This is a problem, because environments are often stored in a subdirectory of the deploy. The solution is to do something like this:
    279 {{{#!sh
    280 mkdir -p /usr/share/trac/projects/my-project
    281 trac-admin /usr/share/trac/projects/my-project initenv
    282 trac-admin /usr/share/trac/projects/my-project deploy /tmp/deploy
    283 mv /tmp/deploy/* /usr/share/trac
    284 }}}
    285 Don't forget to check that the web server has the execution right on scripts in the `/usr/share/trac/cgi-bin` directory.
     279Application scripts for CGI, FastCGI and mod-wsgi can be generated using the [TracAdmin trac-admin] `deploy` command:
     280[[TracAdminHelp(deploy)]]
     281
     282Grant the web server execution right on scripts in the `cgi-bin` directory.
     283
     284For example, the following yields a typical directory structure:
     285{{{#!sh
     286$ mkdir -p /var/trac
     287$ trac-admin /var/trac/<project> initenv
     288$ trac-admin /var/trac/<project> deploy /var/www
     289$ ls /var/www
     290cgi-bin htdocs
     291$ chmod ugo+x /var/www/cgi-bin/*
     292}}}
    286293
    287294==== Mapping Static Resources
    288295
    289 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''' and will cause abysmal performance).
    290 
    291 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.
    292 
    293 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.
    294 
    295 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 `deploy` command:
    296 [[TracAdminHelp(deploy)]]
    297 
    298 The target `<directory>` will then contain an `htdocs` directory with:
    299  - `site/` - a copy of the environment's directory `htdocs/`
    300  - `common/` - the static resources of Trac itself
    301  - `<plugins>/` - one directory for each resource directory managed by the plugins enabled for this environment
    302 
    303 ===== Example: Apache and `ScriptAlias` #ScriptAlias-example
    304 
    305 Assuming the deployment has been done this way:
    306 {{{#!sh
    307 $ trac-admin /var/trac/env deploy /path/to/shared/trac
    308 }}}
    309 
    310 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:
     296Without 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.
     297
     298Web servers such as [https://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.
     299
     300There 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.
     301
     302A single `/chrome` alias can used if the static resources are extracted for all plugins. This means that the `deploy` command (discussed in the previous section) 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.
     303
     304The `deploy` command creates an `htdocs` directory with:
     305 - `common/` - the static resources of Trac
     306 - `site/` - a copy of the environment's `htdocs/` directory
     307 - `shared` - the static resources shared by multiple Trac environments, with a location defined by the `[inherit]` `htdocs_dir` option
     308 - `<plugin>/` - one directory for each resource directory provided by the plugins enabled for this environment
     309
     310The 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:
    311311{{{#!apache
    312312Alias /trac/chrome/common /path/to/trac/htdocs/common
    313313Alias /trac/chrome/site /path/to/trac/htdocs/site
     314Alias /trac/chrome/shared /path/to/trac/htdocs/shared
     315Alias /trac/chrome/<plugin> /path/to/trac/htdocs/<plugin>
     316}}}
     317
     318===== Example: Apache and `ScriptAlias` #ScriptAlias-example
     319
     320Assuming the deployment has been done this way:
     321{{{#!sh
     322$ trac-admin /var/trac/<project> deploy /var/www
     323}}}
     324
     325Add 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:
     326{{{#!apache
     327Alias /trac/chrome /path/to/trac/htdocs
    314328
    315329<Directory "/path/to/www/trac/htdocs">
    316   Order allow,deny
    317   Allow from all
     330  # For Apache 2.2
     331  <IfModule !mod_authz_core.c>
     332    Order allow,deny
     333    Allow from all
     334  </IfModule>
     335  # For Apache 2.4
     336  <IfModule mod_authz_core.c>
     337    Require all granted
     338  </IfModule>
    318339</Directory>
    319340}}}
    320341
    321 If using mod_python, you might want to add this too (otherwise, the alias will be ignored):
     342If using mod_python, add this too, otherwise the alias will be ignored:
    322343{{{#!apache
    323 <Location "/trac/chrome/common/">
     344<Location "/trac/chrome/common">
    324345  SetHandler None
    325346</Location>
    326347}}}
    327348
    328 Note that we mapped the `/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.
    329 
    330 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):
     349Alternatively, 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:
    331350{{{#!apache
    332351Alias /trac/chrome/site /path/to/projectenv/htdocs
    333352
    334353<Directory "/path/to/projectenv/htdocs">
    335   Order allow,deny
    336   Allow from all
     354  # For Apache 2.2
     355  <IfModule !mod_authz_core.c>
     356    Order allow,deny
     357    Allow from all
     358  </IfModule>
     359  # For Apache 2.4
     360  <IfModule mod_authz_core.c>
     361    Require all granted
     362  </IfModule>
    337363</Directory>
    338364}}}
    339365
    340 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:
     366Another alternative to aliasing `/trac/chrome/common` is having Trac generate direct links for those static resources (and only those), using the [TracIni#trac-section htdocs_location] configuration setting:
    341367{{{#!ini
    342368[trac]
    343369htdocs_location = http://static.example.org/trac-common/
    344370}}}
    345 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]).
     371
     372Note that this makes it easy to have a dedicated domain serve those static resources, preferentially cookie-less.
    346373
    347374Of 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:
     
    350377}}}
    351378
    352 ==== Setting up the Plugin Cache
     379==== Setting up the Plugin Cache #egg-cache
    353380
    354381Some Python plugins need to be extracted to a cache directory. By default the cache resides in the home directory of the current user. When running Trac on a Web Server as a dedicated user (which is highly recommended) who has no home directory, this might prevent the plugins from starting. To override the cache location you can set the `PYTHON_EGG_CACHE` environment variable. Refer to your server documentation for detailed instructions on how to set environment variables.
     382
     383If you setup hook scripts that call Trac, such as the Subversion post-commit hook script provided in the `/contrib` directory, make sure you define the `PYTHON_EGG_CACHE` environment variable within these scripts as well.
    355384
    356385== Configuring Authentication