145 | | |
146 | | - upgrade to the latest trunk development version (0.13dev): |
147 | | {{{ |
148 | | easy_install -U Trac==dev |
149 | | }}} |
150 | | |
151 | | For upgrades, reading the TracUpgrade page is mandatory, of course. |
152 | | |
153 | | === From source |
154 | | If you want more control, you can download the source in archive form, or do a checkout from one of the official [[Trac:TracRepositories|source code repositories]]. |
155 | | |
156 | | Be sure to have the prerequisites already installed. You can also obtain the Genshi and Babel source packages from http://www.edgewall.org and follow for them a similar installation procedure, or you can just easy_install those, see [#Usingeasy_install above]. |
157 | | |
158 | | Once you've unpacked the Trac archive or performed the checkout, move in the top-level folder and do: |
159 | | {{{ |
160 | | $ python ./setup.py install |
161 | | }}} |
162 | | |
163 | | ''You'll need root permissions or equivalent for this step.'' |
164 | | |
165 | | This will byte-compile the python source code and install it as an .egg file or folder in the `site-packages` directory |
166 | | of your Python installation. The .egg will also contain all other resources needed by standard Trac, such as htdocs and templates. |
167 | | |
168 | | The script will also install the [wiki:TracAdmin trac-admin] command-line tool, used to create and maintain [wiki:TracEnvironment project environments], as well as the [wiki:TracStandalone tracd] standalone server. |
169 | | |
170 | | If you install from source and want to make Trac available in other languages, make sure Babel is installed. Only then, perform the `install` (or simply redo the `install` once again afterwards if you realize Babel was not yet installed): |
171 | | {{{ |
172 | | $ python ./setup.py install |
173 | | }}} |
174 | | Alternatively, you can do a `bdist_egg` and copy the .egg from dist/ to the place of your choice, or you can create a Windows installer (`bdist_wininst`). |
175 | | |
176 | | === Advanced Options === |
177 | | |
178 | | To install Trac to a custom location, or find out about other advanced installation options, run: |
179 | | {{{ |
180 | | easy_install --help |
181 | | }}} |
182 | | |
183 | | Also see [http://docs.python.org/inst/inst.html Installing Python Modules] for detailed information. |
184 | | |
185 | | Specifically, you might be interested in: |
186 | | {{{ |
187 | | easy_install --prefix=/path/to/installdir |
188 | | }}} |
189 | | or, if installing Trac to a Mac OS X system: |
190 | | {{{ |
191 | | easy_install --prefix=/usr/local --install-dir=/Library/Python/2.5/site-packages |
192 | | }}} |
193 | | Note: If installing on Mac OS X 10.6 running {{{ easy_install http://svn.edgewall.org/repos/trac/trunk }}} will install into {{{ /usr/local }}} and {{{ /Library/Python/2.6/site-packages }}} by default |
194 | | |
195 | | The above will place your `tracd` and `trac-admin` commands into `/usr/local/bin` and will install the Trac libraries and dependencies into `/Library/Python/2.5/site-packages`, which is Apple's preferred location for third-party Python application installations. |
| 124 | Note that in this case you won't have the possibility to run a localized version of Trac; |
| 125 | either use a released version or install from source |
| 126 | |
| 127 | More information can be found on the [trac: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 the sections on [#RunningtheStandaloneServer Running The Standalone Server] and [#RunningTraconaWebServer Running Trac on a Web Server]. |
| 131 | }}} |
209 | | {{{ |
210 | | pip -E /opt/user/trac install trac mysql-python |
211 | | }}} |
212 | | |
213 | | Make sure your OS specific headers are available for pip to automatically build PostgreSQL (libpq-dev) or MySQL (libmysqlclient-dev) bindings. |
214 | | |
215 | | pip will automatically resolve all dependencies (like Genshi, pygments, etc.) and download the latest packages on pypi.python.org and create a self contained installation in /opt/user/trac . |
216 | | |
217 | | All commands (tracd, trac-admin) are available in /opt/user/trac/bin. This can also be leveraged for mod_python (using !PythonHandler directive) and mod_wsgi (using WSGIDaemonProcess directive) |
218 | | |
219 | | Additionally, you can install several trac plugins (listed [http://pypi.python.org/pypi?:action=search&term=trac&submit=search here]) through pip. |
220 | | |
221 | | |
222 | | |
223 | | == Creating a Project Environment == |
224 | | |
225 | | A [TracEnvironment Trac environment] is the backend storage where Trac stores information like wiki pages, tickets, reports, settings, etc. An environment is basically a directory that contains a human-readable [TracIni configuration file], and various other files and directories. |
226 | | |
227 | | A new environment is created using [wiki:TracAdmin trac-admin]: |
228 | | {{{ |
| 145 | {{{#!sh |
| 146 | pip install trac mysql-python |
| 147 | }}} |
| 148 | |
| 149 | Make sure your OS specific headers are available for pip to automatically build PostgreSQL (`libpq-dev`) or MySQL (`libmysqlclient-dev`) bindings. |
| 150 | |
| 151 | pip will automatically resolve all dependencies (like Genshi, pygments, etc.), download the latest packages from pypi.python.org and create a self contained installation in `/opt/user/trac`. |
| 152 | |
| 153 | All commands (`tracd`, `trac-admin`) are available in `/opt/user/trac/bin`. This can also be leveraged for `mod_python` (using `PythonHandler` directive) and `mod_wsgi` (using `WSGIDaemonProcess` directive) |
| 154 | |
| 155 | Additionally, you can install several Trac plugins (listed [https://pypi.python.org/pypi?:action=browse&show=all&c=516 here]) through pip. |
| 156 | |
| 157 | === From source |
| 158 | Using the python-typical setup at the top of the source directory also works. You can obtain the source for a .tar.gz or .zip file corresponding to a release (e.g. `Trac-1.0.tar.gz`) from the [trac:TracDownload] page, or you can get the source directly from the repository. See [trac:TracRepositories#OfficialSubversionrepository TracRepositories] for details. |
| 159 | |
| 160 | {{{#!sh |
| 161 | $ python ./setup.py install |
| 162 | }}} |
| 163 | |
| 164 | ''You will need root permissions or equivalent for this step.'' |
| 165 | |
| 166 | This will byte-compile the Python source code and install it as an .egg file or folder in the `site-packages` directory |
| 167 | of your Python installation. The .egg will also contain all other resources needed by standard Trac, such as `htdocs` and `templates`. |
| 168 | |
| 169 | If you install from source and want to make Trac available in other languages, make sure Babel is installed. Only then, perform the `install` (or simply redo the `install` once again afterwards if you realize Babel was not yet installed): |
| 170 | {{{#!sh |
| 171 | $ python ./setup.py install |
| 172 | }}} |
| 173 | Alternatively, you can run `bdist_egg` and copy the .egg from `dist/` to the place of your choice, or you can create a Windows installer (`bdist_wininst`). |
| 174 | |
| 175 | === Using installer |
| 176 | |
| 177 | On Windows Trac can be installed using the exe installers available on the [trac:TracDownload] page. Installers are available for the 32 and 64 bit versions of Python. Make sure to use the installer that matches the architecture of your Python installation. |
| 178 | |
| 179 | === Using package manager |
| 180 | |
| 181 | Trac may be available in the package repository for your platform. Note however, that the version provided by the package manager may not be the latest release. |
| 182 | |
| 183 | === Advanced `easy_install` Options |
| 184 | |
| 185 | To install Trac to a custom location, or find out about other advanced installation options, run: |
| 186 | {{{#!sh |
| 187 | easy_install --help |
| 188 | }}} |
| 189 | |
| 190 | Also see [http://docs.python.org/2/install/index.html Installing Python Modules] for detailed information. |
| 191 | |
| 192 | Specifically, you might be interested in: |
| 193 | {{{#!sh |
| 194 | easy_install --prefix=/path/to/installdir |
| 195 | }}} |
| 196 | or, if installing Trac on a Mac OS X system: |
| 197 | {{{#!sh |
| 198 | easy_install --prefix=/usr/local --install-dir=/Library/Python/2.5/site-packages |
| 199 | }}} |
| 200 | Note: If installing on Mac OS X 10.6 running {{{ easy_install http://svn.edgewall.org/repos/trac/trunk }}} will install into {{{ /usr/local }}} and {{{ /Library/Python/2.5/site-packages }}} by default. |
| 201 | |
| 202 | The above will place your `tracd` and `trac-admin` commands into `/usr/local/bin` and will install the Trac libraries and dependencies into `/Library/Python/2.5/site-packages`, which is Apple's preferred location for third-party Python application installations. |
| 203 | |
| 204 | == Creating a Project Environment |
| 205 | |
| 206 | A [TracEnvironment Trac environment] is the backend where Trac stores information like wiki pages, tickets, reports, settings, etc. An environment is basically a directory that contains a human-readable [TracIni configuration file], and other files and directories. |
| 207 | |
| 208 | A new environment is created using [TracAdmin trac-admin]: |
| 209 | {{{#!sh |
263 | | == Running Trac on a Web Server == |
264 | | |
265 | | Trac provides various options for connecting to a "real" web server: [wiki:TracCgi CGI], [wiki:TracFastCgi FastCGI], [wiki:TracModWSGI mod_wsgi] and [wiki:TracModPython mod_python]. For decent performance, it is recommended that you use either FastCGI or mod_wsgi. |
266 | | |
267 | | Trac also supports [trac:TracOnWindowsIisAjp AJP] which may be your choice if you want to connect to IIS. |
268 | | |
269 | | ==== Generating the Trac cgi-bin directory ==== |
270 | | |
271 | | 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 [wiki:TracAdmin trac-admin]. |
272 | | |
273 | | There is, however, a bit of a chicken-and-egg problem. The [wiki: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: |
274 | | {{{ |
| 251 | {{{#!div style="border: 1pt dotted; margin: 1em" |
| 252 | **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. |
| 253 | |
| 254 | 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`. |
| 255 | {{{#!sh |
| 256 | export PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1 |
| 257 | }}} |
| 258 | |
| 259 | Alternatively, the variable can be set in the shell before executing `tracd`: |
| 260 | {{{#!sh |
| 261 | $ PKG_RESOURCES_CACHE_ZIP_MANIFESTS=1 tracd --port 8000 /path/to/myproject |
| 262 | }}} |
| 263 | }}} |
| 264 | |
| 265 | === Running Trac on a Web Server |
| 266 | |
| 267 | Trac provides various options for connecting to a "real" web server: |
| 268 | - [TracFastCgi FastCGI] |
| 269 | - [wiki:TracModWSGI mod_wsgi] |
| 270 | - [TracModPython mod_python] |
| 271 | - //[TracCgi CGI] (should not be used, as the performance is far from optimal)// |
| 272 | |
| 273 | 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. |
| 274 | |
| 275 | ==== Generating the Trac cgi-bin directory #cgi-bin |
| 276 | |
| 277 | 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]. |
| 278 | |
| 279 | 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: |
| 280 | {{{#!sh |
280 | | |
281 | | ==== Setting up the Plugin Cache ==== |
282 | | |
283 | | Some 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. |
284 | | |
285 | | == Configuring Authentication == |
286 | | |
287 | | The process of adding, removing, and configuring user accounts for authentication depends on the specific way you run Trac. The basic procedure is described in the [wiki:TracCgi#AddingAuthentication "Adding Authentication"] section on the TracCgi page. To learn how to setup authentication for the frontend you're using, please refer to one of the following pages: |
288 | | |
289 | | * TracStandalone if you use the standalone server, `tracd`. |
290 | | * TracCgi if you use the CGI or FastCGI web front ends. |
291 | | * [wiki:TracModWSGI] if you use the Apache mod_wsgi web front end. |
292 | | * TracModPython if you use the Apache mod_python web front end. |
293 | | |
294 | | |
295 | | == Automatic reference to the SVN changesets in Trac tickets == |
296 | | |
297 | | You can configure SVN to automatically add a reference to the changeset into the ticket comments, whenever changes are committed to the repository. The description of the commit needs to contain one of the following formulas: |
298 | | * '''`Refs #123`''' - to reference this changeset in `#123` ticket |
299 | | * '''`Fixes #123`''' - to reference this changeset and close `#123` ticket with the default status ''fixed'' |
300 | | |
301 | | This functionality requires a post-commit hook to be installed as described in [wiki:TracRepositoryAdmin#ExplicitSync TracRepositoryAdmin], and enabling the optional commit updater components by adding the following line to the `[components]` section of your [wiki:TracIni#components-section trac.ini], or enabling the components in the "Plugins" admin panel. |
302 | | {{{ |
303 | | tracopt.ticket.commit_updater.* = enabled |
304 | | }}} |
305 | | For more information, see the documentation of the `CommitTicketUpdater` component in the "Plugins" admin panel. |
306 | | |
307 | | == Using Trac == |
| 286 | Don't forget to check that the web server has the execution right on scripts in the `/usr/share/trac/cgi-bin` directory. |
| 287 | |
| 288 | ==== Mapping Static Resources |
| 289 | |
| 290 | 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). |
| 291 | |
| 292 | 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. |
| 293 | |
| 294 | 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. |
| 295 | |
| 296 | 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: |
| 297 | [[TracAdminHelp(deploy)]] |
| 298 | |
| 299 | The target `<directory>` will then contain an `htdocs` directory with: |
| 300 | - `site/` - a copy of the environment's directory `htdocs/` |
| 301 | - `common/` - the static resources of Trac itself |
| 302 | - `<plugins>/` - one directory for each resource directory managed by the plugins enabled for this environment |
| 303 | |
| 304 | ===== Example: Apache and `ScriptAlias` #ScriptAlias-example |
| 305 | |
| 306 | Assuming the deployment has been done this way: |
| 307 | {{{#!sh |
| 308 | $ trac-admin /var/trac/env deploy /path/to/shared/trac |
| 309 | }}} |
| 310 | |
| 311 | 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: |
| 312 | {{{#!apache |
| 313 | Alias /trac/chrome/common /path/to/trac/htdocs/common |
| 314 | Alias /trac/chrome/site /path/to/trac/htdocs/site |
| 315 | |
| 316 | <Directory "/path/to/www/trac/htdocs"> |
| 317 | Order allow,deny |
| 318 | Allow from all |
| 319 | </Directory> |
| 320 | }}} |
| 321 | |
| 322 | If using mod_python, you might want to add this too (otherwise, the alias will be ignored): |
| 323 | {{{#!apache |
| 324 | <Location "/trac/chrome/common/"> |
| 325 | SetHandler None |
| 326 | </Location> |
| 327 | }}} |
| 328 | |
| 329 | 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. |
| 330 | |
| 331 | 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): |
| 332 | {{{#!apache |
| 333 | Alias /trac/chrome/site /path/to/projectenv/htdocs |
| 334 | |
| 335 | <Directory "/path/to/projectenv/htdocs"> |
| 336 | Order allow,deny |
| 337 | Allow from all |
| 338 | </Directory> |
| 339 | }}} |
| 340 | |
| 341 | 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: |
| 342 | {{{#!ini |
| 343 | [trac] |
| 344 | htdocs_location = http://static.example.org/trac-common/ |
| 345 | }}} |
| 346 | 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]). |
| 347 | |
| 348 | Of 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: |
| 349 | {{{#!sh |
| 350 | $ ln -s /path/to/trac/htdocs/common /var/www/static.example.org/trac-common |
| 351 | }}} |
| 352 | |
| 353 | ==== Setting up the Plugin Cache |
| 354 | |
| 355 | Some 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. |
| 356 | |
| 357 | == Configuring Authentication |
| 358 | |
| 359 | Trac uses HTTP authentication. You'll need to configure your webserver to request authentication when the `.../login` URL is hit (the virtual path of the "login" button). Trac will automatically pick the `REMOTE_USER` variable up after you provide your credentials. Therefore, all user management goes through your web server configuration. Please consult the documentation of your web server for more info. |
| 360 | |
| 361 | The process of adding, removing, and configuring user accounts for authentication depends on the specific way you run Trac. |
| 362 | |
| 363 | Please refer to one of the following sections: |
| 364 | * TracStandalone#UsingAuthentication if you use the standalone server, `tracd`. |
| 365 | * [wiki:TracModWSGI#ConfiguringAuthentication TracModWSGI#ConfiguringAuthentication] if you use the Apache web server, with any of its front end: `mod_wsgi` of course, but the same instructions applies also for `mod_python`, `mod_fcgi` or `mod_fastcgi`. |
| 366 | * TracFastCgi if you're using another web server with FCGI support (Cherokee, Lighttpd, !LiteSpeed, nginx) |
| 367 | |
| 368 | The following document also contains some useful information for beginners: [trac:TracAuthenticationIntroduction]. |
| 369 | |
| 370 | == Granting admin rights to the admin user |
| 371 | Grant admin rights to user admin: |
| 372 | {{{#!sh |
| 373 | $ trac-admin /path/to/myproject permission add admin TRAC_ADMIN |
| 374 | }}} |
| 375 | This user will have an "Admin" entry menu that will allow you to administrate your Trac project. |
| 376 | |
| 377 | == Finishing the install |
| 378 | |
| 379 | === Enable version control components |
| 380 | |
| 381 | Support for version control systems is provided by optional components in Trac and the components are disabled by default //(since 1.0)//. Subversion and Git must be explicitly enabled if you wish to use them. See TracRepositoryAdmin for more details. |
| 382 | |
| 383 | The version control systems are enabled by adding the following to the `[components]` section of your [TracIni#components-section trac.ini], or enabling the components in the "Plugins" admin panel. |
| 384 | |
| 385 | {{{#!ini |
| 386 | tracopt.versioncontrol.svn.* = enabled |
| 387 | }}} |
| 388 | |
| 389 | {{{#!ini |
| 390 | tracopt.versioncontrol.git.* = enabled |
| 391 | }}} |
| 392 | |
| 393 | After enabling the components, repositories can be configured through the //Repositories// admin panel or by editing [TracIni#repositories-section trac.ini]. Automatic changeset references can be inserted as ticket comments by configuring [TracRepositoryAdmin#Automaticchangesetreferencesintickets CommitTicketUpdater]. |
| 394 | |
| 395 | === Using Trac |