Changes between Version 1 and Version 2 of TracFastCgi


Ignore:
Timestamp:
Jun 21, 2008, 6:11:58 PM (16 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracFastCgi

    v1 v2  
    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
     3Since 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
     7There are two FastCGI modules commonly available for Apache: `mod_fastcgi` and
     8`mod_fcgid`.  The `FastCgiIpcDir` and `FastCgiConfig` directives discussed
     9below are `mod_fastcgi` directives; the `DefaultInitEnv` is a `mod_fgcid`
     10directive.
     11
     12For `mod_fastcgi`, add the following to an appropriate Apache configuration
     13file:
    1414{{{
    1515# Enable fastcgi for .fcgi files
     
    2222LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
    2323}}}
    24 デフォルトの設定に問題がなければ、 `FastCgiIpcDir` の設定は必須ではありません。 `LoadModule` の行は `IfModule` グループの後になければいけないことに注意して下さい。
    25 
    26 `ScriptAlias` を設定するもしくは似たオプションが TracCgi で説明されていますが、
    27 `trac.cgi` の代わりに `trac.fcgi` を呼びます。
    28 
    29 `TRAC_ENV` を以下のように設定することができます:
     24Setting `FastCgiIpcDir` is optional if the default is suitable. Note that the `LoadModule` line must be after the `IfModule` group.
     25
     26Configure `ScriptAlias` or similar options as described in TracCgi, but
     27calling `trac.fcgi` instead of `trac.cgi`.
     28
     29You can set up the `TRAC_ENV` as an overall default:
    3030{{{
    3131FastCgiConfig -initial-env TRAC_ENV=/path/to/env/trac
    3232}}}
    3333
    34 もしくは複数の Trac プロジェクトを扱っているときは、このように設定します:
     34Or you can serve multiple Trac projects in a directory like:
    3535{{{
    3636FastCgiConfig -initial-env TRAC_ENV_PARENT_DIR=/parent/dir/of/projects
    3737}}}
    3838
    39 これらの設定は、 `mod_fcgid` では動きません。似ていますが
    40 `mod_fcgid` での部分的な解決策は以下の通りになります:
     39But neither of these will work for `mod_fcgid`.  A similar but partial
     40solution for `mod_fcgid` is:
    4141{{{
    4242DefaultInitEnv TRAC_ENV /path/to/env/trac/
    4343}}}
    44 しかし、これは `Directory` や `Location` コンテキストで使用することができません。
    45 よって、複数のプロジェクトに対応するのは難しくなります。
    46 
    47 これらのモジュールの両方 (同様に [http://www.lighttpd.net/ lighttpd] と CGI も) で動かすよりよい方法は、
    48 `trac.fcgi` に以下の値を設定することです。
    49 Web サーバに環境変数を設定する必要がなくなります。例:
     44But this cannot be used in `Directory` or `Location` context, which makes it
     45difficult to support multiple projects.
     46
     47A better method which works for both of these modules (and for  [http://www.lighttpd.net/ lighttpd] and CGI as well), because it involves
     48no server configuration settings for environment variables, is to set one
     49of the variables in `trac.fcgi`, e.g.:
    5050{{{
    5151import os
     
    5858}}}
    5959
    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 に以下の行を追加します:
     60Using this method, different projects can be supported by using different
     61`.fcgi` scripts with different `ScriptAliases`, copying and appropriately
     62renaming `trac.fcgi` and adding the above code to create each such script.
     63
     64== Simple Lighttpd Configuration ==
     65
     66The FastCGI front-end was developed primarily for use with alternative webservers, such as [http://www.lighttpd.net/ lighttpd].
     67
     68lighttpd is a secure, fast, compliant and very flexible web-server that has been optimized for high-performance
     69environments.  It has a very low memory footprint compared to other web servers and takes care of CPU load.
     70
     71For using `trac.fcgi` with lighttpd add the following to your lighttpd.conf:
    7272{{{
    7373fastcgi.server = ("/trac" =>
     
    8383}}}
    8484
    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` に以下の設定を追加します:
     85Note 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,
     86and you may set one of the two in `trac.fcgi` instead of in `lighttpd.conf`
     87using `bin-environment` (as in the section above on Apache configuration).
     88
     89For using two projects with lighttpd add the following to your `lighttpd.conf`:
    9090{{{
    9191fastcgi.server = ("/first" =>
     
    109109                )
    110110}}}
    111 各フィールドの値が異なることに注意して下さい。もし `.fcgi` スクリプトに
    112 環境変数を設定するほうが好ましい場合は、 `trac.fcgi` をコピー / 名前変更をして下さい。例として、
    113 `first.fcgi` と `second.fcgi` が上記の設定では参照されるようにします。
    114 上記の設定で、両方のプロジェクトが 同じ `trac.fcgi` スクリプトで起動していても、
    115 異なるプロセスになることに注意して下さい。
     111Note that field values are different.  If you prefer setting the environment
     112variables 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.
     114Note that the above will result in different processes in any event, even
     115if both are running from the same `trac.fcgi` script.
    116116{{{
    117117#!html
    118118<p style="background: #fdc; border: 2px solid #d00; font-style: italic; padding: 0 .5em; margin: 1em 0;">
    119 <strong>Note from c00i90wn:</strong> server.modules をロードする順番はとても重要です。もし、 mod_auth が mod_fastcgi より <strong> 先に </strong> ロードされる設定になっていない場合、サーバはユーザの認証に失敗します。
     119<strong>Note from c00i90wn:</strong> It's very important the order on which server.modules are loaded, if mod_auth is not loaded <strong>BEFORE</strong> mod_fastcgi, then the server will fail to authenticate the user.
    120120</p>
    121121}}}
    122 認証のために lighttpd.conf の 'server.modules' 中で mod_auth を有効にして、 auth.backend と認証方法を選択して下さい:
     122For authentication you should enable mod_auth in lighttpd.conf 'server.modules', select auth.backend and auth rules:
    123123{{{
    124124server.modules              = (
     
    158158
    159159}}}
    160 パスワードファイルがない場合、 lighttpd (確認したバージョンは 1.4.3) が停止するので注意して下さい。
    161 
    162 バージョン 1.3.16 以前では lighttpd は 'valid-user' をサポートしていないので注意してください。
    163 
    164 条件付の設定は静的リソースをマッピングするときに便利です。例として FastCGI を経由せずに直接イメージファイルや CSS を参照するときなどです。:
     160Note that lighttpd (I use version 1.4.3) stopped if password file doesn't exist.
     161
     162Note that lighttpd doesn't support 'valid-user' in versions prior to 1.3.16.
     163
     164Conditional configuration is also useful for mapping static resources, i.e. serving out images and CSS directly instead of through FastCGI:
    165165{{{
    166166# Aliasing functionality is needed
     
    186186}
    187187}}}
    188 複数のプロジェクトのそれぞれにエイリアスを作れば、複数のプロジェクトを動かすのは技術的には簡単です。 fastcgi.server を条件ブロックの中で宣言しラッピングします。
    189 複数のプロジェクトをハンドルするもう一つの方法があります。 TRAC_ENV_PARENT_DIR を TRAC_ENV の代わりに使用し、グローバルの認証機構を使用します。サンプルを見てみましょう:
     188The technique can be easily adapted for use with multiple projects by creating aliases for each of them, and wrapping the fastcgi.server declarations inside conditional configuration blocks.
     189Also there is another way to handle multiple projects and it's to use TRAC_ENV_PARENT_DIR instead of TRAC_ENV and use global auth, let's see an example:
    190190{{{
    191191#  This is for handling multiple projects
     
    217217}}}
    218218
    219 lighttpd では環境変数の LC_TIME を上書きして、日付/時間のフォーマットを変更することも出来ます。
     219Changing date/time format also supported by lighttpd over environment variable LC_TIME
    220220{{{
    221221fastcgi.server = ("/trac" =>
     
    231231                 )
    232232}}}
    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 経由でアクセスできると仮定します:
     233For details about languages specification see TracFaq question 2.13.
     234
     235Other 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
     237If you use trac-0.9, read [http://lists.edgewall.com/archive/trac/2005-November/005311.html about small bug]
     238
     239Relaunch lighttpd, and browse to `http://yourhost.example.org/trac` to access Trac.
     240
     241Note 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
     248The FastCGI front-end was developed primarily for use with alternative webservers, such as [http://www.litespeedtech.com/ LiteSpeed].
     249
     250LiteSpeed 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
     252Setup
     253
     2541) Please make sure you have first have a working install of a Trac project. Test install with “tracd” first.
     255
     2562) 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:
    257257
    258258{{{
     
    260260}}}
    261261
    262 3) "!TracVhost → External AApps" タブへ移動し、新しい "External Application" を作成します。
     2623) Go “TracVhost → External Apps” tab and create a new “External Application”.
    263263
    264264{{{
     
    278278}}}
    279279
    280 4) (非必須) "!TracVhost → Security" タブへ移動し、新しいセキュリティ "Realm" を作成することができます。
     2804) Optional. If you need to use htpasswd based authentication. Go to “TracVhost → Security” tab and create a new security “Realm”.
    281281
    282282{{{
     
    286286}}}
    287287
    288 もし、 htpasswd ファイルを持っていない、もしくは作り方を知らない場合は、 http://sherylcanter.com/encrypt.php にアクセスし、ユーザ名:パスワード の一対を生成して下さい。
    289 
    290 5) "!PythonVhost → Contexts" へ移動し、新しい "FCGI Context" を作成します。
     288If you don’t have a htpasswd file or don’t know how to create the entries within one, go to http://sherylcanter.com/encrypt.php, to generate the user:password combos.
     289
     2905) Go to “PythonVhost → Contexts” and create a new “FCGI Context”.
    291291
    292292{{{
     
    296296}}}
    297297
    298 6) /fullpathto/mytracproject/conf/trac.ini を修正します。
     2986) Modify /fullpathto/mytracproject/conf/trac.ini
    299299
    300300{{{
     
    305305}}}
    306306
    307 7) [http://trac.edgewall.org/wiki/LiteSpeed LiteSpeed] を "lswsctrl restart" で再起動し、新しい Trac プロジェクトに以下の URL でアクセスします:
     3077) Restart LiteSpeed, “lswsctrl restart”, and access your new Trac project at:
    308308
    309309{{{
     
    312312
    313313----
    314 See also: TracCgi, TracModPython, TracInstall, TracGuide
     314See also TracCgi, TracModPython, TracInstall, TracGuide