1 | | = Trac を FastCGI で使用する = |
2 | | |
3 | | バージョン 0.9 以降、 Trac は [http://www.fastcgi.com/ FastCGI] インタフェースに対応するようになりました。 [wiki:TracModPython mod_python] 同様、 Trac を常駐させるため、外部の各リクエストに対して新しいプロセスを生成する CGI インタフェースよりも処理速度が速いです。その上 `mod_python` とは異なり [http://httpd.apache.org/docs/suexec.html SuEXEC] に対応することも可能です。また、より多くの種類の Web サーバにサポートされています。 |
4 | | |
5 | | == 単純な Apache の設定 == |
6 | | |
7 | | Apache で利用可能な FastCGI モジュールは 2 種類あります: `mod_fastcgi` と |
8 | | `mod_fcgid` です。 これ以降に書かれている `FastCgiIpcDir` と `FastCgiConfig` ディレクティブ |
9 | | は `mod_fastcgi` のディレクティブです; `DefaultInitEnv` は `mod_fgcid` |
10 | | のディレクティブです。 |
11 | | |
12 | | `mod_fastcgi` では、 Apache の設定ファイルに以下の設定を追記します。 |
13 | | ファイル: |
| 1 | = Trac with FastCGI = |
| 2 | |
| 3 | Since version 0.9, Trac supports being run through the [http://www.fastcgi.com/ FastCGI] interface. Like [wiki:TracModPython mod_python], this allows Trac to remain resident, and is faster than external CGI interfaces which must start a new process for each request. However, unlike mod_python, it is able to support [http://httpd.apache.org/docs/suexec.html SuEXEC]. Additionally, it is supported by much wider variety of web servers. |
| 4 | |
| 5 | == Simple Apache configuration == |
| 6 | |
| 7 | There are two FastCGI modules commonly available for Apache: `mod_fastcgi` and |
| 8 | `mod_fcgid`. The `FastCgiIpcDir` and `FastCgiConfig` directives discussed |
| 9 | below are `mod_fastcgi` directives; the `DefaultInitEnv` is a `mod_fgcid` |
| 10 | directive. |
| 11 | |
| 12 | For `mod_fastcgi`, add the following to an appropriate Apache configuration |
| 13 | file: |
24 | | デフォルトの設定に問題がなければ、 `FastCgiIpcDir` の設定は必須ではありません。 `LoadModule` の行は `IfModule` グループの後になければいけないことに注意して下さい。 |
25 | | |
26 | | `ScriptAlias` を設定するもしくは似たオプションが TracCgi で説明されていますが、 |
27 | | `trac.cgi` の代わりに `trac.fcgi` を呼びます。 |
28 | | |
29 | | `TRAC_ENV` を以下のように設定することができます: |
| 24 | Setting `FastCgiIpcDir` is optional if the default is suitable. Note that the `LoadModule` line must be after the `IfModule` group. |
| 25 | |
| 26 | Configure `ScriptAlias` or similar options as described in TracCgi, but |
| 27 | calling `trac.fcgi` instead of `trac.cgi`. |
| 28 | |
| 29 | You can set up the `TRAC_ENV` as an overall default: |
44 | | しかし、これは `Directory` や `Location` コンテキストで使用することができません。 |
45 | | よって、複数のプロジェクトに対応するのは難しくなります。 |
46 | | |
47 | | これらのモジュールの両方 (同様に [http://www.lighttpd.net/ lighttpd] と CGI も) で動かすよりよい方法は、 |
48 | | `trac.fcgi` に以下の値を設定することです。 |
49 | | Web サーバに環境変数を設定する必要がなくなります。例: |
| 44 | But this cannot be used in `Directory` or `Location` context, which makes it |
| 45 | difficult to support multiple projects. |
| 46 | |
| 47 | A better method which works for both of these modules (and for [http://www.lighttpd.net/ lighttpd] and CGI as well), because it involves |
| 48 | no server configuration settings for environment variables, is to set one |
| 49 | of the variables in `trac.fcgi`, e.g.: |
60 | | プロジェクトごとの `ScriptAliases` と `.fcgi` スクリプトを設定すれば、 |
61 | | この方法を使用して複数のプロジェクトに対応することができます。 |
62 | | `trac.fcgi` をコピーして、ファイル名を適切に変更し、上記のコードをそれぞれのスクリプトに追記します。 |
63 | | |
64 | | == 単純な Lighttpd の設定 == |
65 | | |
66 | | FastCGI フロントエンドは最初 [http://www.lighttpd.net/ lighttpd] のような、 Apache 以外の Web サーバのために開発されました。 |
67 | | |
68 | | lighttpd はセキュアで高速で、規格に準拠したとても柔軟な Web サーバで、高いパフォーマンスの環境で最適化されます。 |
69 | | 他の Web サーバに比べて CPU や、メモリの占有率がとても少ないです。 |
70 | | |
71 | | `trac.fcgi` を lighttpd で使用するためには、 lighttpd.conf に以下の行を追加します: |
| 60 | Using this method, different projects can be supported by using different |
| 61 | `.fcgi` scripts with different `ScriptAliases`, copying and appropriately |
| 62 | renaming `trac.fcgi` and adding the above code to create each such script. |
| 63 | |
| 64 | == Simple Lighttpd Configuration == |
| 65 | |
| 66 | The FastCGI front-end was developed primarily for use with alternative webservers, such as [http://www.lighttpd.net/ lighttpd]. |
| 67 | |
| 68 | lighttpd is a secure, fast, compliant and very flexible web-server that has been optimized for high-performance |
| 69 | environments. It has a very low memory footprint compared to other web servers and takes care of CPU load. |
| 70 | |
| 71 | For using `trac.fcgi` with lighttpd add the following to your lighttpd.conf: |
85 | | 動かしたい Trac のインスタンス毎に `fastcgi.server` のエントリを追加する必要があります。別の方法として、、上記の `TRAC_ENV` の代わりに `TRAC_ENV_PARENT_DIR` を使用でき、 |
86 | | `lighttpd.conf` に設定する代わりに `trac.fcgi` ファイルに |
87 | | `bin-environment` (上記の Apache の設定 に書かれています) の2つのうちのどちらかを設定します。 |
88 | | |
89 | | lighttpd で2つのプロジェクトを動かすには、 `lighttpd.conf` に以下の設定を追加します: |
| 85 | Note that you will need to add a new entry to `fastcgi.server` for each separate Trac instance that you wish to run. Alternatively, you may use the `TRAC_ENV_PARENT_DIR` variable instead of `TRAC_ENV` as described above, |
| 86 | and you may set one of the two in `trac.fcgi` instead of in `lighttpd.conf` |
| 87 | using `bin-environment` (as in the section above on Apache configuration). |
| 88 | |
| 89 | For using two projects with lighttpd add the following to your `lighttpd.conf`: |
111 | | 各フィールドの値が異なることに注意して下さい。もし `.fcgi` スクリプトに |
112 | | 環境変数を設定するほうが好ましい場合は、 `trac.fcgi` をコピー / 名前変更をして下さい。例として、 |
113 | | `first.fcgi` と `second.fcgi` が上記の設定では参照されるようにします。 |
114 | | 上記の設定で、両方のプロジェクトが 同じ `trac.fcgi` スクリプトで起動していても、 |
115 | | 異なるプロセスになることに注意して下さい。 |
| 111 | Note that field values are different. If you prefer setting the environment |
| 112 | variables in the `.fcgi` scripts, then copy/rename `trac.fcgi`, e.g., to |
| 113 | `first.fcgi` and `second.fcgi`, and reference them in the above settings. |
| 114 | Note that the above will result in different processes in any event, even |
| 115 | if both are running from the same `trac.fcgi` script. |
233 | | 使用言語指定の詳細については [http://trac.lighttpd.net/trac/wiki/TracFaq TracFaq] の 2.13 の質問を参照して下さい。 |
234 | | |
235 | | その他重要な情報、例えば、 [http://trac.lighttpd.net/trac/wiki/TracInstall lighttpd の TracInstall] や、 [wiki:TracCgi#静的なリソースをマッピングする TracCgi] などは fast-cgi 固有ではありませんが、インストールの詳細をつかむのに有用でしょう。 |
236 | | |
237 | | trac-0.9 を使用している場合、[http://lists.edgewall.com/archive/trac/2005-November/005311.html 些細なバグ] について読んでください。 |
238 | | |
239 | | lighttpd を再起動し、ブラウザに `http://yourhost.example.org/trac` を入力して、 Trac にアクセスして下さい。 |
240 | | |
241 | | 制限された権限で lighttpd を起動するにあたって気をつけること: |
242 | | |
243 | | もし、 trac.fcgi が lighttpd の設定で __server.username = "www-data"__ や __server.groupname = "www-data"__ を設定しても起動せずどうしようもないときは、 `bin-environment` セクションの `PYTHON_EGG_CACHE` を `www-data` のホームディレクトリまたは `www-data` アカウントで書き込みが可能なディレクトリに設定して下さい。 (訳注: debian 系 Linux に限定した話だと思われます。 `www-data` は lighttpd を起動するユーザに適宜読み替えてください。) |
244 | | |
245 | | |
246 | | == 簡単な [http://trac.edgewall.org/wiki/LiteSpeed LiteSpeeed] の設定 == |
247 | | |
248 | | FastCGI フロントエンドは最初 [http://www.litespeedtech.com/ LiteSpeed] のような、 Apache 以外の Web サーバのために開発されました。 |
249 | | |
250 | | [http://trac.edgewall.org/wiki/LiteSpeed LiteSpeed] Web サーバはイベント駆動、非同期型であり、Apache に代わるものとしてセキュアで拡張可能になるようにゼロからデザインされています。そして、最低限のリソースで操作できます。 [http://trac.edgewall.org/wiki/LiteSpeed LiteSpeed] は Apache の設定ファイルから直接操作でき、ビジネスに不可欠な環境をターゲットにしています。 |
251 | | |
252 | | セットアップ |
253 | | |
254 | | 1) 最初に Trac プロジェクトをインストールして動作することを確認して下さい。最初のインストールでは、 "tracd" を使用します。 |
255 | | |
256 | | 2) このセットアップでは仮想ホストを作成します。以下、この仮想ホストのことを !TracVhost と呼びます。このチュートリアルで、先ほど作ったプロジェクトが以下の URL 経由でアクセスできると仮定します: |
| 233 | For details about languages specification see TracFaq question 2.13. |
| 234 | |
| 235 | Other important information like [http://trac.lighttpd.net/trac/wiki/TracInstall this updated TracInstall page], [wiki:TracCgi#MappingStaticResources and this] are useful for non-fastcgi specific installation aspects. |
| 236 | |
| 237 | If you use trac-0.9, read [http://lists.edgewall.com/archive/trac/2005-November/005311.html about small bug] |
| 238 | |
| 239 | Relaunch lighttpd, and browse to `http://yourhost.example.org/trac` to access Trac. |
| 240 | |
| 241 | Note about running lighttpd with reduced permissions: |
| 242 | |
| 243 | If nothing else helps and trac.fcgi doesn't start with lighttpd settings __server.username = "www-data"__, __server.groupname = "www-data"__, then in the `bin-environment` section set `PYTHON_EGG_CACHE` to the home directory of `www-data` or some other directory accessible to this account for writing. |
| 244 | |
| 245 | |
| 246 | == Simple LiteSpeed Configuration == |
| 247 | |
| 248 | The FastCGI front-end was developed primarily for use with alternative webservers, such as [http://www.litespeedtech.com/ LiteSpeed]. |
| 249 | |
| 250 | LiteSpeed web server is an event-driven asynchronous Apache replacement designed from the ground-up to be secure, scalable, and operate with minimal resources. LiteSpeed can operate directly from an Apache config file and is targeted for business-critical environments. |
| 251 | |
| 252 | Setup |
| 253 | |
| 254 | 1) Please make sure you have first have a working install of a Trac project. Test install with “tracd” first. |
| 255 | |
| 256 | 2) Create a Virtual Host for this setup. From now on we will refer to this vhost as TracVhost. For this tutorial we will be assuming that your trac project will be accessible via: |