| 1 | | = Tracd = |
| 2 | | |
| 3 | | Tracd is a lightweight standalone Trac web server. |
| 4 | | It can be used in a variety of situations, from a test or development server to a multiprocess setup behind another web server used as a load balancer. |
| 5 | | |
| 6 | | == Pros == |
| 7 | | |
| 8 | | * Fewer dependencies: You don't need to install apache or any other web-server. |
| 9 | | * Fast: Should be almost as fast as the [wiki:TracModPython mod_python] version (and much faster than the [wiki:TracCgi CGI]), even more so since version 0.12 where the HTTP/1.1 version of the protocol is enabled by default |
| 10 | | * Automatic reloading: For development, Tracd can be used in ''auto_reload'' mode, which will automatically restart the server whenever you make a change to the code (in Trac itself or in a plugin). |
| 11 | | |
| 12 | | == Cons == |
| 13 | | |
| 14 | | * Fewer features: Tracd implements a very simple web-server and is not as configurable or as scalable as Apache httpd. |
| 15 | | * No native HTTPS support: [http://www.rickk.com/sslwrap/ sslwrap] can be used instead, |
| 16 | | or [http://trac.edgewall.org/wiki/STunnelTracd stunnel -- a tutorial on how to use stunnel with tracd] or Apache with mod_proxy. |
| 17 | | |
| 18 | | == Usage examples == |
| 19 | | |
| 20 | | A single project on port 8080. (http://localhost:8080/) |
| | 1 | ** Note: このページのドキュメントは Trac 1.0 に対応しています。それ以前のバージョンについては [[0.12/TracStandalone]] を参照してください。 ** |
| | 2 | = Tracd = #Tracd |
| | 3 | |
| | 4 | Tracd は軽量なスタンドアロンの Trac web サーバです。 |
| | 5 | Tracd は様々な場面で使用することができます。テストや開発用のサーバからロードバランサとして使用されているもう一つのウェブサーバの後段に複数のプロセスを配置するときなどに使われます。 |
| | 6 | |
| | 7 | == 利点 == #Pros |
| | 8 | |
| | 9 | * 依存性が低い: apache その他 web サーバをインストールする必要がありません |
| | 10 | * 速い: [wiki:TracModPython mod_python] バージョンと同じくらい速いでしょう。 ([wiki:TracCgi CGI] よりはずっと速い)。そして、 バージョン 0.12 以降では、デフォルトで HTTP のバージョン 1.1 が使えるようになりました |
| | 11 | * 自動リロード: 開発のために、 Tracd は ''auto_reload'' モードを使用しています。そのため、コード ( Trac 自身またはプラグインのコード ) を更新したときに、自動的にサーバが再起動します |
| | 12 | |
| | 13 | == 欠点 == #Cons |
| | 14 | |
| | 15 | * 機能が少ない: Tracd に実装されている web サーバはとてもシンプルで、 Apache httpd のように拡張性のある設定ができません |
| | 16 | * ネイティブで HTTPS に対応しない: 代わりに [http://www.rickk.com/sslwrap/ sslwrap] または |
| | 17 | [trac:STunnelTracd stunnel -- tracd と stunnel を使うためのチュートリアル] または Apache の mod_proxy を使用します |
| | 18 | |
| | 19 | == 使用例 == #Usageexamples |
| | 20 | |
| | 21 | 単一のプロジェクトをポート 8080 でホストします。 (http://localhost:8080/) |
| 71 | | Note that, if the !AppDirectory is set as above, the paths of the executable ''and'' of the script name and parameter values are relative to the directory. This makes updating Python a little simpler because the change can be limited, here, to a single point. |
| 72 | | (This is true for the path to the .htpasswd file, as well, despite the documentation calling out the /full/path/to/htpasswd; however, you may not wish to store that file under the Python directory.) |
| 73 | | }}} |
| 74 | | |
| 75 | | For Windows 7 User, srvany.exe may not be an option, so you can use [http://www.google.com/search?q=winserv.exe WINSERV] utility and run: |
| | 72 | Note: もし !AppDirectory が上記のように設定されているならば、実行ファイル ''と'' スクリプトのパス、パラメータの値は、設定したフォルダへの相対パスになります。ここ一点に絞って言うと、これにより Python をアップデートするときに変更箇所が限定されるため少しだけ楽になります。 |
| | 73 | (ドキュメントでは、 /full/path/to/htpasswd とフルパス指定するよう書いてあるかもしれませんが、これは、 .htpasswd ファイルについても同様のことが言えます。このファイルを Python ディレクトリ配下に配置したいと思わないかもしれません。) |
| | 74 | }}} |
| | 75 | |
| | 76 | Windows 7 ユーザは、 srvany.exe は使用できないかもしれません。代わりに [http://www.google.com/search?q=winserv.exe WINSERV] ユーティリティを使用して、起動してください: |
| 102 | | where: |
| 103 | | * '''base_project_dir''': the base directory of the project specified as follows: |
| 104 | | * when serving multiple projects: ''relative'' to the `project_path` |
| 105 | | * when serving only a single project (`-s`): the name of the project directory |
| 106 | | Don't use an absolute path here as this won't work. ''Note:'' This parameter is case-sensitive even for environments on Windows. |
| 107 | | * '''password_file_path''': path to the password file |
| 108 | | * '''realm''': the realm name (can be anything) |
| 109 | | * '''project_path''': path of the project |
| 110 | | |
| 111 | | * **`--auth`** in the above means use Digest authentication, replace `--auth` with `--basic-auth` if you want to use Basic auth. Although Basic authentication does not require a "realm", the command parser does, so the second comma is required, followed directly by the closing quote for an empty realm name. |
| 112 | | |
| 113 | | Examples: |
| | 103 | オプションについて: |
| | 104 | * '''base_project_dir''': 下記の通りプロジェクトのベースのディレクトリを特定する: |
| | 105 | * 複数のプロジェクトを立てているとき: `project_path` への ''相対パス'' |
| | 106 | * 1 つのみプロジェクトを立てているとき (`-s` オプション使用): プロジェクトのディレクトリの名前 |
| | 107 | 絶対パスを使用しないで下さい。 ''Note:'' このパラメータは、 Windows の環境であっても大文字小文字を区別します。 |
| | 108 | * '''password_file_path''': パスワードファイルへのパス |
| | 109 | * '''realm''': realm の名前 ( なんでも指定できます ) |
| | 110 | * '''project_path''': プロジェクトへのパス |
| | 111 | |
| | 112 | * **`--auth`** 上記の例では、ダイジェスト認証を使用しています。基本認証を使用する際は `--auth` を `--basic-auth` に置き換えてください。基本認証は "realm" を必要としませんが、コマンドとしては、最後の引用句に空のレルム名前が直接続くことになるので、2つ目のコンマは必要になります |
| | 113 | |
| | 114 | 例: |
| 135 | | === Basic Authorization: Using a htpasswd password file === |
| 136 | | This section describes how to use `tracd` with Apache .htpasswd files. |
| 137 | | |
| 138 | | Note: It is necessary (at least with Python 2.6) to install the fcrypt package in order to |
| 139 | | decode the htpasswd format. Trac source code attempt an `import crypt` first, but there |
| 140 | | is no such package for Python 2.6. |
| 141 | | |
| 142 | | To create a .htpasswd file use Apache's `htpasswd` command (see [#GeneratingPasswordsWithoutApache below] for a method to create these files without using Apache): |
| | 136 | === 基本認証: htpasswd パスワードを使用する === #BaseicAuthorizationUsingahtpasswdpasswordfile |
| | 137 | このセクションでは、 `tracd` と Apache の .htpasswd ファイルの使用方法について記述します。 |
| | 138 | |
| | 139 | Note: htpasswd のフォーマットを解読するために、(少なくとも Python 2.6 は) fcrypt パッケージをインストールする必要があります。 |
| | 140 | Trac のソースコードでは、まず `import crypt` を試みますが、 |
| | 141 | Python 2.6 にそのようなパッケージはありません。 `SHA-1` パスワードのみ、このモジュールなしで対応します。( Trac 1.0 から) |
| | 142 | |
| | 143 | Apache の `htpasswd` コマンドを使用して、 .htpasswd ファイルを作成します。 ( Apache を使用せずにこれらのファイルを作成する方法については [#GeneratingPasswordsWithoutApache 下記] を参照して下さい): |
| 160 | | ''Note:'' You might need to pass "-m" as a parameter to htpasswd on some platforms (OpenBSD). |
| 161 | | |
| 162 | | === Digest authentication: Using a htdigest password file === |
| 163 | | |
| 164 | | If you have Apache available, you can use the htdigest command to generate the password file. Type 'htdigest' to get some usage instructions, or read [http://httpd.apache.org/docs/2.0/programs/htdigest.html this page] from the Apache manual to get precise instructions. You'll be prompted for a password to enter for each user that you create. For the name of the password file, you can use whatever you like, but if you use something like `users.htdigest` it will remind you what the file contains. As a suggestion, put it in your <projectname>/conf folder along with the [TracIni trac.ini] file. |
| 165 | | |
| 166 | | Note that you can start tracd without the --auth argument, but if you click on the ''Login'' link you will get an error. |
| 167 | | |
| 168 | | === Generating Passwords Without Apache === |
| 169 | | |
| 170 | | Basic Authorization can be accomplished via this [http://aspirine.org/htpasswd_en.html online HTTP Password generator]. Copy the generated password-hash line to the .htpasswd file on your system. Note that Windows Python lacks the "crypt" module that is the default hash type for htpasswd ; Windows Python can grok MD5 password hashes just fine and you should use MD5. |
| 171 | | |
| 172 | | You can use this simple Python script to generate a '''digest''' password file: |
| | 161 | ''Note:'' いくつかのプラットフォーム (OpenBSD) では、htpasswd に "-m" をパラメータで渡す必要があるかもしれません。 |
| | 162 | |
| | 163 | === ダイジェスト認証: htdigest パスワードファイルの設定方法 === #DigestauthentitionUsingahtdigestpasswordfile |
| | 164 | |
| | 165 | もし、 Apache がインストールされているなら、パスワードファイルを生成するのに、 htdigest コマンドを使用することができます。 'htdigest' とタイプして使用方法を見るか、詳細な使用方法を見るために Apache のマニュアルの [http://httpd.apache.org/docs/2.0/programs/htdigest.html このページ] を読んでください。ユーザを作成するたびに、パスワードを入力するように求められます。パスワードファイルの名前には好きな名前をつけることができますが、 `users.htdigest` というような名前にしておけば、ファイルに何が含まれているかを覚えておけるでしょう。このファイルは <projectname>/conf フォルダに [TracIni trac.ini] ファイルと一緒に置いておくとよいでしょう。 |
| | 166 | |
| | 167 | 引数 `--auth` なしで tracd をスタートできることに注意して下さい。ただし、 ''ログイン'' (英語版では ''Login'') リンクをクリックするとエラーになります。 |
| | 168 | |
| | 169 | === Apache 以外の環境でパスワードを生成する === #GeneratingPasswordsWithoutApache |
| | 170 | |
| | 171 | 基本認証は [http://aspirine.org/htpasswd_en.html online HTTP Password generator] を用いて完成させることができます。これは `SHA-1` もサポートしています。生成した password-hash をシステムの .htpasswd ファイルにコピーします。Windows 版の Python は htpasswd のデフォルトのハッシュタイプである "crypt" モジュールに対応していないので注意してください。MD5 パスワードハッシュには対応しているため、MD5 を使用するとよいでしょう。 |
| | 172 | |
| | 173 | 簡単な Python スクリプトで '''digest''' 認証のパスワードファイルを生成できます: |
| 253 | | }}} |
| 254 | | |
| 255 | | Use the -d option so that tracd doesn't hang if you close the terminal window where tracd was started. |
| 256 | | |
| 257 | | == Tips == |
| 258 | | |
| 259 | | === Serving static content === |
| 260 | | |
| 261 | | If `tracd` is the only web server used for the project, |
| 262 | | it can also be used to distribute static content |
| 263 | | (tarballs, Doxygen documentation, etc.) |
| 264 | | |
| 265 | | This static content should be put in the `$TRAC_ENV/htdocs` folder, |
| 266 | | and is accessed by URLs like `<project_URL>/chrome/site/...`. |
| 267 | | |
| 268 | | Example: given a `$TRAC_ENV/htdocs/software-0.1.tar.gz` file, |
| 269 | | the corresponding relative URL would be `/<project_name>/chrome/site/software-0.1.tar.gz`, |
| 270 | | which in turn can be written as `htdocs:software-0.1.tar.gz` (TracLinks syntax) or `[/<project_name>/chrome/site/software-0.1.tar.gz]` (relative link syntax). |
| 271 | | |
| 272 | | ''Support for `htdocs:` TracLinks syntax was added in version 0.10'' |
| 273 | | |
| 274 | | === Using tracd behind a proxy |
| 275 | | |
| 276 | | In some situations when you choose to use tracd behind Apache or another web server. |
| 277 | | |
| 278 | | In this situation, you might experience issues with redirects, like being redirected to URLs with the wrong host or protocol. In this case (and only in this case), setting the `[trac] use_base_url_for_redirect` to `true` can help, as this will force Trac to use the value of `[trac] base_url` for doing the redirects. |
| 279 | | |
| 280 | | If you're using the AJP protocol to connect with `tracd` (which is possible if you have flup installed), then you might experience problems with double quoting. Consider adding the `--unquote` parameter. |
| 281 | | |
| 282 | | See also [trac:TracOnWindowsIisAjp], [trac:TracNginxRecipe]. |
| 283 | | |
| 284 | | === Authentication for tracd behind a proxy |
| 285 | | It is convenient to provide central external authentication to your tracd instances, instead of using {{{--basic-auth}}}. There is some discussion about this in #9206. |
| 286 | | |
| 287 | | Below is example configuration based on Apache 2.2, mod_proxy, mod_authnz_ldap. |
| 288 | | |
| 289 | | First we bring tracd into Apache's location namespace. |
| | 254 | --group=GROUP the group to run as |
| | 255 | --user=USER the user to run as |
| | 256 | }}} |
| | 257 | |
| | 258 | tracd を起動させたターミナルウィンドウを閉じる場合には、tracd がハングアップしないように -d オプションを使用してください。 |
| | 259 | |
| | 260 | == Tips == #Tips |
| | 261 | |
| | 262 | === 静的なリソースを扱う === #Servingstaticcontent |
| | 263 | |
| | 264 | もし、 `tracd` が単一のプロジェクトのみを扱う Web サーバだとしたら、 |
| | 265 | 静的なリソースを割り当てるのに使用することができます。 |
| | 266 | (tar アーカイブ, Doxygen ドキュメントなど) |
| | 267 | |
| | 268 | この静的なリソースは `$TRAC_ENV/htdocs` フォルダに置き、 |
| | 269 | `<project_URL>/chrome/site/...` という URL でアクセスします。 |
| | 270 | |
| | 271 | 例: ファイル名が `$TRAC_ENV/htdocs/software-0.1.tar.gz` だったとき、 |
| | 272 | 対応する URL は `/<project_name>/chrome/site/software-0.1.tar.gz` となります。 |
| | 273 | 代わりに `htdocs:software-0.1.tar.gz` (TracLinks のシンタックス) や `[/<project_name>/chrome/site/software-0.1.tar.gz]` (相対リンクのシンタックス) で記述することができます。 |
| | 274 | |
| | 275 | ''TracLinks における `htdocs:` のサポートは Trac のバージョン 0.10 で追加されました。'' |
| | 276 | |
| | 277 | === tracd をプロキシの背後で使用する === #Usingtracdbehindaproxy |
| | 278 | |
| | 279 | ある状況において tracd を Apache もしくは他のウェブサーバの背後で使用するときについてです。 |
| | 280 | |
| | 281 | この状況において、間違ったホストやプロトコルにリダイレクトされてしまったなどの経験があるかもしれません。この場合 (そして、この場合に限って) `[trac] use_base_url_for_redirect` を `true` に設定することによって、リダイレクトを行なう際 Trac に `[trac] base_url` の値を強制的に使用させることができます。 |
| | 282 | |
| | 283 | もし、`tracd` に接続するために AJP プロトコルを使用しているならば (flup をインストールしているならば可能です) 、ダブルクオテーションの問題にぶつかったことがあるかもしれません。その際は、 `--unquote` パラメータを追加することを考えてください。 |
| | 284 | |
| | 285 | [trac:TracOnWindowsIisAjp], [trac:TracNginxRecipe] も参照してください。 |
| | 286 | |
| | 287 | === プロキシ背後の tracd の認証 === #Authenticationfortracdbehindaproxy |
| | 288 | {{{--basic-auth}}} を使用する代わりに、tracd のインスタンスに外部認証を提供しても有効です。この方法については [trac:#9206 #9206] で議論されています。 |
| | 289 | |
| | 290 | 下記は Apache 2.2 、mod_proxy、mod_authnz_ldap を使用した場合の設定例です。 |
| | 291 | |
| | 292 | まず Apache のネームスペースに tracd を定義します。 |
| 337 | | === Serving a different base path than / === |
| 338 | | Tracd supports serving projects with different base urls than /<project>. The parameter name to change this is |
| | 340 | もしプラグインをすべてのプロジェクトにインストールしたい場合、 [TracPlugins#Plugindiscovery 共有pluginsディレクトリ] に格納し、共有 trac.ini でプラグインのコンポーネントを有効に設定しなければいけません。 |
| | 341 | |
| | 342 | 共有 config (例えば `/srv/trac/conf/trac.ini`): |
| | 343 | {{{ |
| | 344 | [components] |
| | 345 | remote-user-auth.* = enabled |
| | 346 | [inherit] |
| | 347 | plugins_dir = /srv/trac/plugins |
| | 348 | [trac] |
| | 349 | obey_remote_user_header = true |
| | 350 | }}} |
| | 351 | |
| | 352 | 各プロジェクトの config (例えば `/srv/trac/envs/myenv`): |
| | 353 | {{{ |
| | 354 | [inherit] |
| | 355 | file = /srv/trac/conf/trac.ini |
| | 356 | }}} |
| | 357 | |
| | 358 | === / (root) とは異なるベースパスで起動する === #Servingadifferentbasepaththan |
| | 359 | Tracd は /<project> とは異なるベース URL でプロジェクトを提供することをサポートします。変更するためのパラメータは以下の通りです。 |