Changes between Version 3 and Version 4 of TracFastCgi


Ignore:
Timestamp:
Dec 30, 2016, 2:54:46 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracFastCgi

    v3 v4  
    1 [[PageOutline]]
    2 
    3 = Trac を FastCGI で使用する = #TracwithFastCGI
    4 
    5 [http://www.fastcgi.com/ FastCGI] インターフェースを使用すると [wiki:TracModPython mod_python] や [wiki:TracModWSGI mod_wsgi] と同様に Trac を常駐させることができます。リクエスト毎に新しいプロセスを開始しなければならない CGI インターフェースよりも処理速度は速くなります。加えて、多種多様の Web サーバでサポートされています。
    6 
    7 Note: mod_python とは異なり、FastCGI では [http://httpd.apache.org/docs/suexec.html Apache SuEXEC] をサポートしています。つまり、Web サーバを実行しているユーザとは、異なる権限でプログラムを実行することができます。(`mod_wsgi` でサポートしている `WSGIDaemonProcess` におけるユーザ / グループと同じ効果を得ることができます)
    8 
    9 '''Windows 向け:''' Trac の FastCGI は Windows 環境下で動作しません。これは、`_fcgi.py` で用いられる `Socket.fromfd` が Windows では実行されないからです。もし IIS へ接続したい場合は、[trac:TracOnWindowsIisAjp AJP]/[trac:TracOnWindowsIisAjp ISAPI] に挑戦してみて下さい。
    10 
    11 [[PageOutline(2-3,Overview,inline)]]
    12 
    13 
    14 == 単純な Apache の設定 == #SimpleApacheconfiguration
    15 
    16 Apache で利用可能な FastCGI モジュールは 2 種類あります: `mod_fastcgi` と
    17 `mod_fcgid` (推奨) です。後者の方がよりメンテナンスされています。
    18 
    19 次の項目では、FCGI の特定のセットアップに焦点を合わせています。Apache の認証の設定方法については [wiki:TracModWSGI#ConfiguringAuthentication] を参照してください。
    20 
    21 CGI モジュールを使用する場合は注意してください。また、必ず Web サーバに cgi-bin フォルダの実行権限を持たせてください。 FastCGI では詳細な権限に関するエラーが出力されますが、mod_fcgid ではこの処理が行われていない場合には、不明瞭なエラーしか出力されません。(Connection reset by peer: mod_fcgid: error reading data from FastCGI server の様な)
    22 
    23 === `mod_fastcgi` でのセットアップ === #setupwithmod_fastcgi
    24 `mod_fastcgi` では `FastCgiIpcDir` と `FastCgiConfig` ディレクティブを使用して Apache の設定ファイルに設定を行います:
    25 {{{
     1= Trac with FastCGI
     2
     3[[TracGuideToc]]
     4[[PageOutline(2-5, Contents, floated)]]
     5
     6[http://www.fastcgi.com/ FastCGI] interface allows Trac to remain resident much like with [wiki:TracModPython mod_python] or [wiki:TracModWSGI mod_wsgi]. It is faster than external CGI interfaces which must start a new process for each request. Additionally, it is supported by a much wider variety of web servers.
     7
     8Note that unlike mod_python, FastCGI supports [http://httpd.apache.org/docs/suexec.html Apache SuEXEC], ie run with different permissions than the web server runs with. `mod_wsgi` supports the `WSGIDaemonProcess` with user / group parameters to achieve the same effect.
     9
     10'''Note for Windows:''' Trac's FastCGI does not run under Windows, as Windows does not implement `Socket.fromfd`, which is used by `_fcgi.py`. If you want to connect to IIS, you may want to try [trac:TracOnWindowsIisAjp AJP]/[trac:TracOnWindowsIisAjp ISAPI].
     11
     12== Apache configuration
     13
     14There are two FastCGI modules commonly available for Apache: `mod_fastcgi` and `mod_fcgid` (preferred). The latter is more up-to-date.
     15
     16The following sections focus on the FCGI specific setup, see also [wiki:TracModWSGI#ConfiguringAuthentication] for configuring the authentication in Apache.
     17
     18Regardless of which cgi module is used, be sure the web server has executable permissions on the cgi-bin folder. While FastCGI will throw specific permissions errors, mod_fcgid will throw an ambiguous error if this has not been done: `Connection reset by peer: mod_fcgid: error reading data from FastCGI server`.
     19
     20=== Set up with `mod_fastcgi`
     21
     22`mod_fastcgi` uses `FastCgiIpcDir` and `FastCgiConfig` directives that should be added to an appropriate Apache configuration file:
     23{{{#!apache
    2624# Enable fastcgi for .fcgi files
    2725# (If you're using a distro package for mod_fcgi, something like
     
    2927<IfModule mod_fastcgi.c>
    3028   AddHandler fastcgi-script .fcgi
    31    FastCgiIpcDir /var/lib/apache2/fastcgi
     29   FastCgiIpcDir /var/lib/apache2/fastcgi 
    3230</IfModule>
    3331LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
    3432}}}
    35 デフォルトの設定に問題がなければ、 `FastCgiIpcDir` の設定は必須ではありません。 `LoadModule` の行は `IfModule` グループの後になければいけないことに注意して下さい。
    36 
    37 `ScriptAlias` もしくは TracCgi で説明されている類似のオプションを設定しますが、
    38 `trac.cgi` の代わりに `trac.fcgi` を指定してください。
    39 
    40 すべてデフォルトで `TRAC_ENV` をセットアップするつもりならば、Apache の設定ファイルに以下を追加します (`FastCgiIpcDir` より下に):
    41 {{{
     33
     34Setting `FastCgiIpcDir` is optional if the default is suitable. Note that the `LoadModule` line must be after the `IfModule` group.
     35
     36Configure `ScriptAlias` or similar options as described in TracCgi, but calling `trac.fcgi` instead of `trac.cgi`.
     37
     38Add the following to the Apache configuration file (below the `FastCgiIpcDir` line) if you intend to set up the `TRAC_ENV` as an overall default:
     39{{{#!apache
    4240FastCgiConfig -initial-env TRAC_ENV=/path/to/env/trac
    4341}}}
    4442
    45 あるいは、以下を追加することで複数の Trac プロジェクトを提供できます:
    46 {{{
     43Alternatively, you can serve multiple Trac projects in a directory by adding this:
     44{{{#!apache
    4745FastCgiConfig -initial-env TRAC_ENV_PARENT_DIR=/parent/dir/of/projects
    4846}}}
    4947
    50 === `mod_fcgid` でのセットアップ === #Setupwithmod_fcgid
    51 `ScriptAlias` を設定します。 (詳細は TracCgi を参照してください)、 ただし
    52 trac.cgi` の代わりに `trac.fcgi` を呼び出します。 Note: 最後のスラッシュを忘れずに。とても重要です。
    53 {{{
     48=== Set up with `mod_fcgid`
     49
     50Configure `ScriptAlias` (see TracCgi for details), but call `trac.fcgi` instead of `trac.cgi`:
     51{{{#!apache
    5452ScriptAlias /trac /path/to/www/trac/cgi-bin/trac.fcgi/
    5553}}}
    5654
    57 `mod_fcgid` で Trac environment を設定するには `DefaultInitEnv`
    58 ディレクティブを使用します。このディレクティブは `Direcotry` や `Location`
    59 コンテキストで使用できないので、複数のプロジェクトを設定する場合、
    60 以下に記述する Environment を設定する別の方法を試してください。
    61 
    62 {{{
     55Note the slash at the end.
     56
     57To set up Trac environment for `mod_fcgid` it is necessary to use `DefaultInitEnv` directive. It cannot be used in `Directory` or `Location` context, so if you need to support multiple projects, try the alternative environment setup below:
     58{{{#!apache
    6359DefaultInitEnv TRAC_ENV /path/to/env/trac/
    6460}}}
    6561
    66 === Environment を設定する別の方法 === #alternativeenvironmentsetup
    67 Trac environment へのパスを設定するための、より適した方法は、パスを
    68 `trac.fcgi` スクリプト自体に書き込むことです。これによってサーバの環境変数を
    69 設定する必要がなくなり、どちらの !FastCgi モジュール (および
    70 [http://www.lighttpd.net/ lighttpd] や CGI など) でも、動作するようになります:
    71 {{{
     62=== Alternative environment setup
     63
     64A better method to specify the path to the Trac environment is to embed the path into `trac.fcgi` script itself. That doesn't require configuration of the server environment variables, works for both [trac:FastCgi] modules as well as for [http://www.lighttpd.net/ lighttpd] and CGI:
     65{{{#!python
    7266import os
    7367os.environ['TRAC_ENV'] = "/path/to/projectenv"
    7468}}}
    75 または
    76 {{{
     69
     70or:
     71{{{#!python
    7772import os
    7873os.environ['TRAC_ENV_PARENT_DIR'] = "/path/to/project/parent/dir"
    7974}}}
    8075
    81 プロジェクトごとの `ScriptAlias` と `.fcgi` スクリプトを設定すれば、
    82 起動スクリプトに `TRAC_ENV` 等を設定する方法を使用して複数のプロジェクトに対応することができます。
    83 
    84 この [https://coderanger.net/~coderanger/httpd/fcgi_example.conf fcgid 設定例] の通り、 !ScriptAlias ディレクティブでは末尾の / も含めて設定してください:
    85 {{{
     76With this method different projects can be supported by using different `.fcgi` scripts with different `ScriptAliases`.
     77
     78See [https://coderanger.net/~coderanger/httpd/fcgi_example.conf this fcgid example config] which uses a !ScriptAlias directive with trac.fcgi with a trailing / like this:
     79{{{#!apache
    8680ScriptAlias / /srv/tracsite/cgi-bin/trac.fcgi/
    8781}}}
    8882
    89 == Cherokee の簡単な設定 == #SimpleCherokeeConfiguration
    90 
    91 Cherokee 側の設定はとても簡単です。 Trac を SCGI プロセスとして起動できるかどうかのみ知っている必要があります。
    92 Cherokee が起動していないときにはいつでも、 Cherokee が Trac を切り離せるようにすることによって、 Trac を手動で起動することも、いっそのこと自動的に起動することもできます。
    93 最初に、ローカルのインタプリタである cherokee-admin で information source を設定します。
     83== Cherokee Configuration
     84
     85Configuring [http://cherokee-project.com/ Cherokee] with Trac is straightforward, if you spawn Trac as an SCGI process. You can either start it manually, or better yet, automatically by letting Cherokee spawn the server whenever it is down.
     86
     87First set up an information source in cherokee-admin with a local interpreter:
    9488
    9589{{{
     
    10195}}}
    10296
    103 もしそのポート番号に到達できなければ、インタプリタコマンドは起動されたことになります。information source の定義において、 ''ローカルインタプリタ'' の代わりに、 ''リモートホスト'' を ''information source'' として使用するならば、 spawner を手動で起動する必要があることを覚えておいてください。
    104 
    105 そして、 Trac にアクセスするために SCGI ハンドラによって管理される新しいルールを作成しなければなりません。このルールは例えば、 trac.example.net という新しい仮想サーバ内で作成し、 2 つのルールのみを必要とします。 '''デフォルト''' ルールは以前に作成された information source に関する SCGI ハンドラで使用されます。
    106 2 つ目のルールは Trac のインタフェースを正しく表示するために必要ないくつかの静的ファイルを扱うために設定します。ルールを ''/common'' の ''ディレクトリルール'' として作成し、 ''静的ファイル'' のハンドラを適切なファイルをポイントする ''ドキュメントルート'' と共に設定するだけです: ''$TRAC_LOCAL/htdocs/'' ($TRAC_LOCAL はユーザ又はローカル Trac リソース を置いたシステム管理者により定義されたディレクトリです)
    107 
    108 Note:\\
    109 tracd プロセスが起動しない場合や cherokee が 503 エラーページを表示する場合、 [http://trac.saddi.com/flup python-flup] がインストールされていない可能性があります。\\
    110 Python-flup は SCGI の能力を trac に与える従属関係にあります。 debian 基本システムからインストールできます:
    111 {{{
     97If the port was not reachable, the interpreter command would be launched. Note that, in the definition of the information source, you will have to manually launch the spawner if you use a ''Remote host'' as ''Information source'' instead of a ''Local interpreter''.
     98
     99After doing this, we will just have to create a new rule managed by the SCGI handler to access Trac. It can be created in a new virtual server, trac.example.net for instance, and will only need two rules. The '''default''' one will use the SCGI handler associated to the previously created information source.
     100The second rule will be there to serve the few static files needed to correctly display the Trac interface. Create it as ''Directory rule'' for ''/common'' and just set it to the ''Static files'' handler and with a ''Document root'' that points to the appropriate files: ''$TRAC_LOCAL/htdocs/'' (where $TRAC_LOCAL is a directory defined by the user or the system administrator to place local Trac resources).
     101
     102'''Note:''' If the tracd process fails to start up, and Cherokee displays a 503 error page, you might be missing the [http://trac.saddi.com/flup python-flup] package ([trac:#9903]). Python-flup is a dependency which provides Trac with SCGI capability. You can install it on Debian based systems with:
     103{{{#!sh
    112104sudo apt-get install python-flup
    113105}}}
    114106
    115 
    116 == Lighttpd の簡単な設定 == #SimpleLighttpdConfiguration
    117 
    118 FastCGI フロントエンドは最初 [http://www.lighttpd.net/ lighttpd] のような、 Apache 以外の Web サーバのために開発されました。
    119 
    120 lighttpd はセキュアで高速で、規格に準拠したとても柔軟な Web サーバで、高いパフォーマンスの環境で最適化されます。
    121 他の Web サーバに比べて CPU や、メモリの占有率がとても少ないです。
    122 
    123 `trac.fcgi`(0.11 以前) / fcgi_frontend.py (0.11) を lighttpd で使用するためには、 lighttpd.conf に以下の行を追加します:
     107== Lighttpd Configuration
     108
     109The FastCGI front-end was developed primarily for use with alternative webservers, such as [http://www.lighttpd.net/ Lighttpd].
     110
     111Lighttpd is a secure, fast, compliant and very flexible web-server that has been optimized for high-performance environments. It has a very low memory footprint compared to other web servers and takes care of CPU load.
     112
     113For using `trac.fcgi`(prior to 0.11) / fcgi_frontend.py (0.11) with Lighttpd add the following to your lighttpd.conf:
    124114{{{
    125115#var.fcgi_binary="/usr/bin/python /path/to/fcgi_frontend.py" # 0.11 if installed with easy_setup, it is inside the egg directory
    126116var.fcgi_binary="/path/to/cgi-bin/trac.fcgi" # 0.10 name of prior fcgi executable
    127117fastcgi.server = ("/trac" =>
    128 
     118   
    129119                   ("trac" =>
    130120                     ("socket" => "/tmp/trac-fastcgi.sock",
     
    138128}}}
    139129
    140 動かしたい Trac のインスタンス毎に `fastcgi.server` のエントリを追加する必要があります。別の方法として、上記の `TRAC_ENV` の代わりに `TRAC_ENV_PARENT_DIR` を使用でき、
    141 `lighttpd.conf` に設定する代わりに `trac.fcgi` ファイルに
    142 `bin-environment` (上記の Apache の設定 に書かれています) の2つのうちのどちらかを設定します。
    143 
    144 Note: lighttpd には 'SCRIPT_NAME' と 'PATH_INFO' に関するバグがあります。例として、 fastcgi.server の uri が '/trac' とするところを '/' としてしまいます。 ([trac:#2418 本家チケット 2418] 参照) このバグは lighttpd 1.4.23 以降で修正されています。 fastcgi.server のパラメータとして、 `"fix-root-scriptname" => "enable"` を追加する必要があるでしょう。
    145 
    146 lighttpd で2つのプロジェクトを動かすには、 `lighttpd.conf` に以下の設定を追加します:
     130Note 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, and you may set one of the two in `trac.fcgi` instead of in `lighttpd.conf` using `bin-environment`, as in the section above on Apache configuration.
     131
     132Note that Lighttpd has a bug related to 'SCRIPT_NAME' and 'PATH_INFO' when the uri of fastcgi.server is '/' instead of '/trac' in this example (see [trac:#2418]). This is fixed in Lighttpd 1.5, and under Lighttpd 1.4.23 or later the workaround is to add `"fix-root-scriptname" => "enable"` as a parameter of fastcgi.server.
     133
     134For using two projects with lighttpd add the following to your `lighttpd.conf`:
    147135{{{
    148136fastcgi.server = ("/first" =>
     
    166154                )
    167155}}}
    168 Note: 各フィールドの値が異なることに注意して下さい。もし、
    169 `.fcgi` スクリプト内の環境変数を設定する方が好ましいならば、 `trac.fcgi` スクリプトを
    170 例えば、 `first.fcgi` や `second.fcgi` というようにコピー / リネームして、上記設定の中でこれらのスクリプトを参照するようにしてください。
    171 両方のプロジェクトが同じ `trac.fcgi` スクリプトから起動しているとしても、
    172 異なるプロセスになることに注意して下さい。
    173 
    174 {{{
    175 #!div class=important
    176 '''Note''': server.modules をロードする順番はとても重要です。もし、 mod_auth が mod_fastcgi より '''先に''' mod_auth がロードされない設定になっていない場合、サーバはユーザ認証に失敗します。
    177 }}}
    178 
    179 認証のために lighttpd.conf の 'server.modules' 中で mod_auth を有効にして、 auth.backend と認証方法を選択して下さい:
     156
     157Note that the field values are different. If you prefer setting the environment variables in the `.fcgi` scripts, then copy/rename `trac.fcgi`, eg to `first.fcgi` and `second.fcgi`, and reference them in the above settings.
     158Note that the above will result in different processes in any event, even if both are running from the same `trac.fcgi` script.
     159
     160{{{#!div class=important
     161'''Note:''' The order in which the server.modules are loaded is very important: if mod_auth is not loaded '''before''' mod_fastcgi, then the server will fail to authenticate the user.
     162}}}
     163
     164For authentication you should enable mod_auth in lighttpd.conf 'server.modules', select auth.backend and auth rules:
    180165{{{
    181166server.modules              = (
     
    213198               )
    214199
    215 
    216 }}}
    217 Note: パスワードファイルがない場合、 lighttpd (確認したバージョンは 1.4.3) が停止するので注意して下さい。
    218 
    219 Note: バージョン 1.3.16 以前では lighttpd は 'valid-user' をサポートしていないので注意してください。
    220 
    221 条件付の設定は静的リソースをマッピングするときに便利です。例として FastCGI を経由せずに直接イメージファイルや CSS を参照するときなどです:
     200}}}
     201
     202Note that Lighttpd (v1.4.3) stops if the password file doesn't exist.
     203
     204Note that Lighttpd doesn't support 'valid-user' in versions prior to 1.3.16.
     205
     206Conditional configuration is also useful for mapping static resources, ie serving out images and CSS directly instead of through FastCGI:
    222207{{{
    223208# Aliasing functionality is needed
     
    243228}
    244229}}}
    245 複数のプロジェクトのそれぞれにエイリアスを作れば、複数のプロジェクトを動かすのは技術的には簡単です。 fastcgi.server を条件ブロックの中で宣言しラッピングします。
    246 複数のプロジェクトをハンドルするもう一つの方法があります。 TRAC_ENV_PARENT_DIR を TRAC_ENV の代わりに使用し、グローバルの認証機構を使用します。サンプルを見てみましょう:
     230
     231The 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.
     232
     233Also there is another way to handle multiple projects and it uses `TRAC_ENV_PARENT_DIR` instead of `TRAC_ENV` as well as global authentication:
    247234{{{
    248235#  This is for handling multiple projects
     
    274261}}}
    275262
    276 lighttpd では環境変数の LC_TIME を上書きして、日付/時間のフォーマットを変更することも出来ます。
     263Changing date/time format also supported by lighttpd over environment variable LC_TIME:
    277264{{{
    278265fastcgi.server = ("/trac" =>
     
    288275                 )
    289276}}}
    290 使用言語指定の詳細については [http://trac.lighttpd.net/trac/wiki/TracFaq TracFaq] の 2.13 の質問を参照して下さい。
    291 
    292 [wiki:TracInstall#MappingStaticResources 静的なリソースのマッピングに関する事] の様な他の重要な情報は、fastcgi 以外でもインストールの詳細をつかむのに有効です。
    293 ]
    294 
    295 lighttpd を再起動し、ブラウザに `http://yourhost.example.org/trac` を入力して、 Trac にアクセスして下さい。
    296 
    297 制限された権限で lighttpd を起動するにあたって気をつけること:
    298 
    299 もし、 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 を起動するユーザに適宜読み替えてください。)
    300 
    301 
    302 == !LiteSpeed の簡単な設定 == #SimpleLighttpdConfiguration
    303 
    304 FastCGI フロントエンドは最初 [http://www.litespeedtech.com/ LiteSpeed] のような、 Apache 以外の Web サーバのために開発されました。
    305 
    306 !LiteSpeed Web サーバはイベント駆動、非同期型であり、 Apache に代わるものとしてセキュアで拡張可能になるようにゼロからデザインされています。そして、最低限のリソースで操作できます。 !LiteSpeed は Apache の設定ファイルから直接操作でき、ビジネスに不可欠な環境をターゲットにしています。
    307 
    308  1. 最初に Trac プロジェクトをインストールして動作することを確認して下さい。最初のインストールでは、 "tracd" を使用します
    309 
    310  2. このセットアップでは仮想ホストを作成します。以下、この仮想ホストのことを !TracVhost と呼びます。このチュートリアルで、先ほど作ったプロジェクトが以下の URL 経由でアクセスできると仮定します:
    311 
     277
     278For details about languages specification see [trac:TracFaq TracFaq] question 2.13.
     279
     280Other important information like the [wiki:TracInstall#MappingStaticResources mapping static resources advices] are useful for non-fastcgi specific installation aspects.
     281
     282Relaunch Lighttpd and browse to `http://yourhost.example.org/trac` to access Trac.
     283
     284Note about running Lighttpd with reduced permissions: 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.
     285
     286== !LiteSpeed Configuration
     287
     288The FastCGI front-end was developed primarily for use with alternative webservers, such as [http://www.litespeedtech.com/ LiteSpeed].
     289
     290!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.
     291
     292 1. Please make sure you have a working install of a Trac project. Test install with "tracd" first.
     293 1. 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:
    312294{{{
    313295http://yourdomain.com/trac/
    314296}}}
    315 
    316  3. "!TracVhost → External Apps" タブへ移動し、新しい "External Application" を作成します
    317 
    318 {{{
    319 Name: MyTracFCGI
     297 1. Go "!TracVhost → External Apps" tab and create a new "External Application":
     298{{{
     299Name: MyTracFCGI       
    320300Address: uds://tmp/lshttpd/mytracfcgi.sock
    321301Max Connections: 10
     
    325305Persistent Connection   Yes
    326306Connection Keepalive Timeout: 30
    327 Response Bufferring: No
     307Response Bufferring: No 
    328308Auto Start: Yes
    329309Command: /usr/share/trac/cgi-bin/trac.fcgi  <--- path to trac.fcgi
     
    331311Instances: 10
    332312}}}
    333 
    334  4. (非必須) htpasswd ベースの認証を使用するならば、 "!TracVhost → Security" タブへ移動し、新しいセキュリティ "Realm" を作成することができます
    335 
    336 {{{
     313 1. Optional: If you need to use htpasswd based authentication. Go to "!TracVhost → Security" tab and create a new security Realm:
     314 {{{
    337315DB Type: Password File
    338316Realm Name: MyTracUserDB               <--- any name you wish and referenced later
    339317User DB Location: /fullpathto/htpasswd <--- path to your htpasswd file
    340318}}}
    341 
    342 もし、 htpasswd ファイルを持っていない、もしくは作り方を知らない場合は、 http://sherylcanter.com/encrypt.php にアクセスし、ユーザ名:パスワード の一対を生成して下さい。
    343 
    344  5. "!PythonVhost → Contexts" へ移動し、新しい "FCGI Context" を作成します
    345 
    346 {{{
    347 URI: /trac/                              <--- URI path to bind to python fcgi app we created
    348 Fast CGI App: [VHost Level] MyTractFCGI  <--- select the trac fcgi extapp we just created
     319 If 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.
     320 1. Go to "!PythonVhost → Contexts" and create a new FCGI Context:
     321 {{{
     322URI: /trac/                              <--- URI path to bind to python fcgi app we created   
     323Fast CGI App: [VHost Level] MyTractFCGI  <--- select the Trac fcgi extapp we just created
    349324Realm: TracUserDB                        <--- only if (4) is set. select realm created in (4)
    350325}}}
    351 
    352  6. /fullpathto/mytracproject/conf/trac.ini を修正します
    353 
    354 {{{
     326 1. Modify `/fullpathto/mytracproject/conf/trac.ini`:
     327 {{{
    355328#find/set base_rul, url, and link variables
    356329base_url = http://yourdomain.com/trac/ <--- base url to generate correct links to
     
    358331link = http://yourdomain.com/trac/     <--- link of graphic logo
    359332}}}
    360 
    361  7. !LiteSpeed を "lswsctrl restart" で再起動し、新しい Trac プロジェクトに以下の URL でアクセスします:
    362 
    363 {{{
    364 http://yourdomain.com/trac/
    365 }}}
    366 
    367 
    368 == Nginx 簡単な設定 == #SimpleNginxConfiguration
    369 
    370 Nginx は FastCGI プロセスを生成することはできませんが、伝達することができます。そのため、 Trac を独立して FastCGI サーバを開始する必要があります。
    371 
    372  1. 基本認証を行う Nginx の設定 - 0.6.32 で動作することを確認しました
    373 {{{
     333 1. Restart !LiteSpeed: `lswsctrl restart`, and access your new Trac project at {{{http://yourdomain.com/trac/}}}.
     334
     335== Nginx Configuration
     336
     337[http://nginx.org/en/ Nginx] is able to communicate with FastCGI processes, but can not spawn them. So you need to start FastCGI server for Trac separately.
     338
     339 1. Nginx configuration with basic authentication handled by Nginx - confirmed to work on 0.6.32
     340 {{{#!nginx
    374341    server {
    375342        listen       10.9.8.7:443;
     
    386353        ssl_prefer_server_ciphers   on;
    387354
    388         # (Or ``^/some/prefix/(.*)``.
    389         if ($uri ~ ^/(.*)) {
    390              set $path_info /$1;
     355        # it makes sense to serve static resources through Nginx (or ``~ [/some/prefix]/chrome/(.*)``)
     356        location ~ /chrome/(.*) {
     357             alias /home/trac/instance/static/htdocs/$1;
    391358        }
    392359
    393         # it makes sense to serve static resources through Nginx
    394         location /chrome/ {
    395              alias /home/trac/instance/static/htdocs/;
    396         }
    397 
    398         # You can copy this whole location to ``location [/some/prefix]/login``
     360        # You can copy this whole location to ``location [/some/prefix](/login)``
    399361        # and remove the auth entries below if you want Trac to enforce
    400362        # authorization where appropriate instead of needing to authenticate
    401363        # for accessing the whole site.
    402         # (Or ``location /some/prefix``.)
    403         location / {
     364        # (Or ``~ location /some/prefix(/.*)``.)
     365        location ~ (/.*) {
    404366            auth_basic            "trac realm";
    405367            auth_basic_user_file /home/trac/htpasswd;
     
    415377            # (Or ``fastcgi_param  SCRIPT_NAME  /some/prefix``.)
    416378            fastcgi_param  SCRIPT_NAME        "";
    417             fastcgi_param  PATH_INFO          $path_info;
     379            fastcgi_param  PATH_INFO          $1;
    418380
    419381            ## WSGI NEEDED VARIABLES - trac warns about them
     
    438400    }
    439401}}}
    440 
    441  2. trac.fcgi の変更:
    442 
    443 {{{
     402 1. Modified trac.fcgi:
     403 {{{#!python
    444404#!/usr/bin/env python
    445405import os
     
    451411     import trac.web._fcgi
    452412
    453      fcgiserv = trac.web._fcgi.WSGIServer(dispatch_request,
     413     fcgiserv = trac.web._fcgi.WSGIServer(dispatch_request, 
    454414          bindAddress = sockaddr, umask = 7)
    455415     fcgiserv.run()
     
    472432
    473433}}}
    474 
    475  3. nginx をリロードし、 trac.fcgi をこのように起動します:
    476 
    477 {{{
    478 trac@trac.example ~ $ ./trac-standalone-fcgi.py
    479 }}}
    480 
    481 上記設定は以下の条件だと仮定します:
    482  * trac のインスタンスを実行するためのユーザ名を 'trac' とします。ホームディレクトリに trac Environment をおきます
    483  * Trac environment は `/home/trac/instance` に配置します
    484  * `/home/trac/htpasswd` に認証情報が含まれています
    485  * `/home/trac/run` は nginx を起動しているグループが所有しています
    486   * Linux を使用しているならば、 `/home/trac/run` に (`chmod g+s run`) を設定します
    487   * [trac:#7239 本家チケット 7239] のパッチを適用し、ソケットファイルのパーミッションをそのつど修正しなければいけません
    488 
    489 残念ですが、 nginx は fastcgi_pass ディレクティブ内の変数展開をサポートしていません。
    490 したがって、 1 つのサーバーブロックから複数の trac インスタンスを起動することができません。
    491 
    492 セキュリティ面で不安があるならば、 各 Trac インスタンスを別々のユーザで起動してください。
    493 
    494 Trac を FCGI の外部アプリケーションとして起動するもう一つの方法は、[trac:#6224 本家チケット 6224] を参照して下さい。
     434 1. Reload nginx and launch trac.fcgi:
     435 {{{#!sh
     436trac@trac.example ~ $ ./trac-standalone-fcgi.py
     437}}}
     438
     439The above assumes that:
     440 * There is a user named 'trac' for running Trac instances and keeping Trac environments in its home directory
     441 * `/home/trac/instance` contains a Trac environment
     442 * `/home/trac/htpasswd` contains authentication information
     443 * `/home/trac/run` is owned by the same group the Nginx runs under
     444  * and if your system is Linux the `/home/trac/run` has setgid bit set (`chmod g+s run`)
     445  * and patch from [trac:#7239] is applied, or you'll have to fix the socket file permissions every time
     446
     447Unfortunately Nginx does not support variable expansion in fastcgi_pass directive.
     448Thus it is not possible to serve multiple Trac instances from one server block.
     449
     450If you worry enough about security, run Trac instances under separate users.
     451
     452Another way to run Trac as a FCGI external application is offered in [trac:#6224].
    495453
    496454----
    497 See also:  TracGuide, TracInstall, [wiki:TracModWSGI ModWSGI], [wiki:TracCgi CGI], [wiki:TracModPython ModPython], [trac:TracNginxRecipe TracNginxRecipe]
     455See also: TracGuide, TracInstall, [wiki:TracModWSGI ModWSGI], [wiki:TracCgi CGI], [wiki:TracModPython ModPython], [trac:TracNginxRecipe TracNginxRecipe]