XPressME Integration Kit

Trac

Version 1 から Version 2 における更新: TracCgi

差分発生行の前後
Ignore:
Timestamp:
Nov 29, 2010, 3:25:28 PM (13 years 前)
Author:
trac (IP: 127.0.0.1)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracCgi

    v1 v2  
    1 = CGI として Trac をインストールする = #InstallingTracasCGI 
     1= Installing Trac as CGI = 
    22 
    3 Trac を CGI スクリプトとしてインストールするために、 Web サーバが `trac.cgi` を CGI として実行できるようにする必要があります。 
    4  
    5   ''Trac を CGI 経由で使用するのは、他のメソッド [TracModPython mod_python] や [TracFastCgi FastCGI] よりも極めて遅いということに注意して下さい。'' 
    6  
    7 [http://httpd.apache.org/ Apache HTTPD] を使用している場合、設定方法は 2 通りあります: 
    8  
    9  1. `ScriptAlias` を使用し、 `trac.cgi` スクリプトを URL にマップする。 
    10  2. CGI プログラムが実行可能な、 Web サーバ上のディレクトリ (通常は `cgi-bin` が使用される) に `trac.cgi` ファイルをコピーする。シンボリックリンクでも代用できますが、その場合 `cgi-bin` ディレクトリでは `FollowSymLinks` オプションを有効にして下さい。 
    11  
    12 CGI を分かりやすい URL にマッピングできるので、 1 番目のオプションを推奨します。 
    13  
    14 それでは、 Apache の設定ファイルに以下のブロックを追記し、ファイル名とロケーションを変更してください: 
    153{{{ 
    16 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi 
     4#!div class=important 
     5  ''Please note that using Trac via CGI is the slowest deployment method available. It is slower than [TracModPython mod_python], [TracFastCgi FastCGI] and even [trac:TracOnWindowsIisAjp IIS/AJP] on Windows.'' 
    176}}} 
    187 
    19  ''このディレクティブを使用するには `mod_alias` モジュールをインストールし、有効にしておく必要があります。'' 
     8CGI script is the entrypoint that web-server calls when a web-request to an application is made. To generate the `trac.cgi` script run: 
     9{{{ 
     10trac-admin /path/to/env deploy /path/to/www/trac 
     11}}} 
     12`trac.cgi` will be in the `cgi-bin` folder inside the given path. Make sure it is executable by your web server. This command also copies `static resource` files to a `htdocs` directory of a given destination. 
    2013 
    21 Trac のプロジェクトが 1 つの場合、 `TRAC_ENV` 環境変数を使用してプロジェクトへのパスを指定する必要があります: 
     14== Apache web-server configuration == 
     15 
     16In [http://httpd.apache.org/ Apache] there are two ways to run Trac as CGI: 
     17 
     18 1. Use a `ScriptAlias` directive that maps an URL to the `trac.cgi` script (recommended) 
     19 2. Copy the `trac.cgi` file into the directory for CGI executables used by your web server (commonly named `cgi-bin`). You can also create a symbolic link, but in that case make sure that the `FollowSymLinks` option is enabled for the `cgi-bin` directory. 
     20 
     21To make Trac available at `http://yourhost.example.org/trac` add `ScriptAlias` directive to Apache configuration file, changing `trac.cgi` path to match your installation: 
     22{{{ 
     23ScriptAlias /trac /path/to/www/trac/cgi-bin/trac.cgi 
     24}}} 
     25 
     26 ''Note that this directive requires enabled `mod_alias` module.'' 
     27 
     28If you're using Trac with a single project you need to set its location using the `TRAC_ENV` environment variable: 
    2229{{{ 
    2330<Location "/trac"> 
     
    2633}}} 
    2734 
    28 もしくは、複数のプロジェクトを扱うために、それらの親ディレクトリを `TRAC_ENV_PARENT_DIR` を使用して設定することができます。 
     35Or to use multiple projects you can specify their common parent directory using the `TRAC_ENV_PARENT_DIR` variable: 
    2936{{{ 
    3037<Location "/trac"> 
     
    3340}}} 
    3441 
    35  ''`SetEnv` ディレクティブを使用するには `mod_env` モジュールをインストールし有効にしておく必要があります。そうでなければ、 trac.cgi に TRAC_ENV を設定することができます。 "try" と "from trac.web ..." の間に以下のコードを加えてください:'' 
     42 ''Note that the `SetEnv` directive requires enabled `mod_env` module. It is also possible to set TRAC_ENV in trac.cgi. Just add the following code between "try:" and "from trac.web ...":'' 
    3643 
    3744{{{ 
     
    4047}}} 
    4148 
    42  '' もしくは、 TRAC_ENV_PARENT_DIR を設定します: '' 
     49 '' Or for TRAC_ENV_PARENT_DIR: '' 
    4350 
    4451{{{ 
     
    4754}}} 
    4855 
    49 `http://yourhost.example.org/trac` のような URL で Trac が使用できるようになります。 
     56If you are using the [http://httpd.apache.org/docs/suexec.html Apache suEXEC] feature please see [http://trac.edgewall.org/wiki/ApacheSuexec]. 
    5057 
    51 [http://httpd.apache.org/docs/suexec.html Apache suEXEC] 機能を使用している場合、 [http://trac.edgewall.org/wiki/ApacheSuexec ApacheSuexec] を参照して下さい。 
     58On some systems, you ''may'' need to edit the shebang line in the `trac.cgi` file to point to your real Python installation path. On a Windows system you may need to configure Windows to know how to execute a .cgi file (Explorer -> Tools -> Folder Options -> File Types -> CGI). 
    5259 
    53 システムによっては、`trac.cgi` ファイルの shebang 行を編集して、実際に Python がインストールされているパスを指すように修正する必要がある ''かもしれません''。 Windows システム上では、 Windowsが .cgi ファイルを実行できるように設定する必要があるでしょう。 (エクスプローラ -> ツール -> フォルダオプション -> ファイルの種類 -> CGI を Python と関連付ける) 
     60== Mapping Static Resources == 
    5461 
    55 == 静的なリソースをマッピングする == #MappingStaticResources 
     62Out of the box, Trac will pass static resources such as style sheets or images through itself. For a CGI setup this is '''highly undesirable''', because this way CGI script is invoked for documents that could be much more efficiently served directly by web server. 
    5663 
    57 このままでも Trac はスタイルシートや画像ファイルなどの静的なリソースを扱えますが、 CGI のセットアップとしては妥当な設定とは言えません。 Web サーバ自身がはるかに効率良くに直接扱うことができるドキュメントまで、 CGI スクリプトとして呼び出してしまうという結果になるからです。 
     64Web 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 already used this capability by defining a `ScriptAlias` for the CGI script. We also can map requests for static resources directly to the directory on the file system, avoiding processing these requests by CGI script. 
    5865 
    59 [http://httpd.apache.org/ Apache HTTPD] のような Web サーバはリソースに対して "Alias" を設定することで仮想の URL を与え、サーバのファイルシステムのレイアウトとは異なる位置にマップすることができます。すでに CGI スクリプトに対して `ScriptAlias` を定義していますので、ファイルシステム上の静的リソースを含んだコンテンツをマッピングすることで CGI スクリプトの要求を回避します。 
     66There 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. 
    6067 
    61 Apacheの設定ファイルを再び編集して、 CGI スクリプトの `ScriptAlias` を追記したブロックより '''上に''' 以下のブロックを追記します。ファイル名とロケーションは適宜変更してください (訳注: 0.11 以降は、静的リソースは Trac をインストールした場所の `trac/htdocs` になります): 
     68Add the following snippet to Apache configuration '''before''' the `ScriptAlias` for the CGI script, changing paths to match your deployment: 
    6269{{{ 
    63 Alias /trac/chrome/common /usr/share/trac/htdocs 
    64 <Directory "/usr/share/trac/htdocs"> 
     70Alias /trac/chrome/common /path/to/trac/htdocs 
     71<Directory "/path/to/www/trac/htdocs"> 
    6572  Order allow,deny 
    6673  Allow from all 
     
    6875}}} 
    6976 
    70 `trac.cgi` スクリプトにどんな URL をマッピングしたとしても、 `/chrome/common` というパスでは静的リソースのロケーションを使用するようになります。 
     77Note that we mapped `/trac` part of the URL to the `trac.cgi` script, and the path `/chrome/common` is the path you have to append to that location to intercept requests to the static resources.  
    7178 
    72 例えば、Trac が `/cgi-bin/trac.cgi` にマッピングされているとしたら、 Alias の URL は `cgi-bin/trac.cgi/chrome/common` となります。 
     79For example, if Trac is mapped to `/cgi-bin/trac.cgi` on your server, the URL of the Alias should be `/cgi-bin/trac.cgi/chrome/common`. 
    7380 
    74 同様に、静的なリソースを使用している場合、 プロジェクトディレクトリの htdocs に Apache の設定を行うことが出来ます (再度、 CGI スクリプトの `ScriptAlias` を追記したブロックより '''上に'''、以下のブロックを追記します。ファイル名とロケーションは適宜変更してください): 
     81Similarly, if you have static resources in a project's htdocs directory (which is referenced by /chrome/site URL in themes), you can configure Apache to serve those resources (again, put this '''before''' the `ScriptAlias` for the CGI script, and adjust names and locations to match your installation): 
    7582 
    7683{{{ 
     
    8289}}} 
    8390 
    84 あるいは、[wiki:TracIni trac.ini] に `htdocs_location` のオプションを設定することができます。 
     91Alternatively to hacking `/trac/chrome/site`, you can directly specify path to static resources using `htdocs_location` configuration option in [wiki:TracIni trac.ini]: 
    8592{{{ 
    8693[trac] 
    87 htdocs_location = /trac-htdocs 
     94htdocs_location = http://yourhost.example.org/trac-htdocs 
    8895}}} 
    8996 
    90 Trac は HTML ページに静的リソースを組み込むときに、この URL を使用するようになります。もちろん、それでも、特定の URL が指定されたときに 例えば、 Web サーバーのドキュメントルートにディレクトリをコピーするなり、シンボリックリンクを張るなりして、Web サーバ経由で、 Trac が `htdocs` ディレクトリを利用できるようにしておく必要があります: 
     97Trac will then use this URL when embedding static resources into HTML pages. Of course, you still need to make the Trac `htdocs` 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: 
    9198{{{ 
    92 $ ln -s /usr/share/trac/htdocs /var/www/your_site.com/htdocs/trac-htdocs 
     99$ ln -s /path/to/www/trac/htdocs /var/www/yourhost.example.org/trac-htdocs 
    93100}}} 
    94101 
    95 Note: `htdocs` ディレクトリの内容を取得するには、最初に TracAdmin の `deploy` コマンドを使用して、対応する Trac リソースを展開する必要があります。 
     102Note that in order to get this `htdocs` directory, you need first to extract the relevant Trac resources using the `deploy` command of TracAdmin: 
    96103[[TracAdminHelp(deploy)]] 
    97104 
    98105 
    99 == 認証を追加する == #AddingAuthentication 
     106== Adding Authentication == 
    100107 
    101 Apache で認証を追加する最も単純な方法はパスワードファイルを作ることです。 `htpasswd` プログラムを使用してパスワードファイルを作成します: 
     108The simplest way to enable authentication with Apache is to create a password file. Use the `htpasswd` program to create the password file: 
    102109{{{ 
    103110$ htpasswd -c /somewhere/trac.htpasswd admin 
     
    107114}}} 
    108115 
    109 一番最初のユーザ以外は "-c" オプションは必要ありません: 
     116After the first user, you dont need the "-c" option anymore: 
    110117{{{ 
    111118$ htpasswd /somewhere/trac.htpasswd john 
     
    115122}}} 
    116123 
    117   ''`htpasswd` についての詳細は man を見てください。'' 
     124  ''See the man page for `htpasswd` for full documentation.'' 
    118125 
    119 ユーザを作成した後、 TracPermissions の記述通りユーザに権限を設定することができます。 
     126After you've created the users, you can set their permissions using TracPermissions. 
    120127 
    121 Apache の設定ファイルの中にパスワードファイル名を記述し、認証を有効にする必要があります: 
     128Now, you'll need to enable authentication against the password file in the Apache configuration: 
    122129{{{ 
    123130<Location "/trac/login"> 
     
    129136}}} 
    130137 
    131 複数のプロジェクトを持っている場合でも、パスワードファイルはプロジェクトで共通なものを使用することができます: 
     138If you're hosting multiple projects you can use the same password file for all of them: 
    132139{{{ 
    133140<LocationMatch "/trac/[^/]+/login"> 
     
    139146}}} 
    140147 
    141 より堅固なセキュリティのために、 SSL を有効にするか、少なくとも "基本認証" の代わりに "ダイジェスト認証" を使用することを推奨します。より詳しい情報については [http://httpd.apache.org/docs/2.0/ Apache HTTPD documentation] を参照して下さい。例えば、Dian 4.0r1 (etch) システムの上では、Apache 構成における関連セクションは下記のように記述できます。 
     148For better security, it is recommended that you either enable SSL or at least use the “digest” authentication scheme instead of “Basic”. Please read the [http://httpd.apache.org/docs/2.0/ Apache HTTPD documentation] to find out more. For example, on a Debian 4.0r1 (etch) system the relevant section  in apache configuration can look like this: 
    142149{{{ 
    143150<Location "/trac/login"> 
     
    146153    AuthName "trac" 
    147154    AuthDigestDomain /trac 
    148     AuthDigestFile /somewhere/trac.htpasswd 
     155    AuthUserFile /somewhere/trac.htpasswd 
    149156    Require valid-user 
    150157</Location> 
    151158}}} 
    152 .htpasswd ファイルは htpasswd の代わりに htdigest を使って、以下の通りに作成する必要があります: 
     159and you'll have to create your .htpasswd file with htdigest instead of htpasswd as follows: 
    153160{{{ 
    154161# htdigest /somewhere/trac.htpasswd trac admin 
    155162}}} 
    156 上記の "trac" パラメータは 上の !AuthName と同じ値にします (apache-docs の "Realm")。 
     163where the "trac" parameter above is the same as !AuthName above  ("Realm" in apache-docs).  
    157164 
    158165---- 
    159 See also:  TracGuide, TracInstall, TracFastCgi, TracModPython 
     166See also:  TracGuide, TracInstall, [wiki:TracModWSGI], TracFastCgi, TracModPython