Changes between Version 3 and Version 4 of TracCgi
- Timestamp:
- Jan 28, 2010, 4:25:36 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracCgi
v3 v4 1 = CGI として Trac をインストールする=1 = Installing Trac as CGI = 2 2 3 T rac を CGI スクリプトとしてインストールするために、 Web サーバが `trac.cgi` を CGI として実行できるようにする必要があります。3 To install Trac as a CGI script, you need to make the `trac.cgi` executable as a CGI by your web server. 4 4 5 '' Trac を CGI 経由で使用するのは、他のメソッド [TracModPython mod_python] や [TracFastCgi FastCGI] よりも極めて遅いということに注意して下さい。''5 ''Please note that using Trac via CGI is significantly slower than any other deployment method, such as [TracModPython mod_python] or [TracFastCgi FastCGI].'' 6 6 7 [http://httpd.apache.org/ Apache HTTPD] を使用している場合、設定方法は 2 通りあります:7 If you're using [http://httpd.apache.org/ Apache HTTPD], there are a couple ways to do that: 8 8 9 1. `ScriptAlias` を使用し、 `trac.cgi` スクリプトを URL にマップする。10 2. C GI プログラムが実行可能な、Web サーバ上のディレクトリ (通常は `cgi-bin` が使用される) に `trac.cgi` ファイルをコピーする。シンボリックリンクでも代用できますが、その場合 `cgi-bin` ディレクトリでは `FollowSymLinks` オプションを有効にして下さい。9 1. Use a `ScriptAlias` to map a URL to the `trac.cgi` script 10 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. 11 11 12 CGI を分かりやすい URL にマッピングできるので、 1 番目のオプションを推奨します。 12 The first option is recommended as it also allows you to map the CGI to a friendly URL. 13 13 14 それでは、 Apache の設定ファイルに以下のブロックを追記し、ファイル名とロケーションを変更してください:14 Now, edit the Apache configuration file and add this snippet, file names and locations changed to match your installation: 15 15 {{{ 16 16 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi 17 17 }}} 18 18 19 '' このディレクティブを使用するには `mod_alias` モジュールをインストールし、有効にしておく必要があります。''19 ''Note that this directive requires the `mod_alias` module to be installed and enabled.'' 20 20 21 Trac のプロジェクトが 1 つの場合、 `TRAC_ENV` 環境変数を使用してプロジェクトへのパスを指定する必要があります:21 If you're using Trac with a single project you need to set its location using the `TRAC_ENV` environment variable: 22 22 {{{ 23 23 <Location "/trac"> … … 26 26 }}} 27 27 28 もしくは、複数のプロジェクトを扱うために、それらの親ディレクトリを `TRAC_ENV_PARENT_DIR` を使用して設定することができます。 28 Or to use multiple projects you can specify their common parent directory using the `TRAC_ENV_PARENT_DIR` variable: 29 29 {{{ 30 30 <Location "/trac"> … … 33 33 }}} 34 34 35 '' `SetEnv` ディレクティブを使用するには `mod_env` モジュールをインストールし有効にしておく必要があります。''35 ''Note that the `SetEnv` directive requires the `mod_env` module to be installed and enable. If not, you could set TRAC_ENV in trac.cgi. Just add the following code between "try:" and "from trac.web ...":'' 36 36 37 `http://yourhost.example.org/trac` のような URL で Trac が使用できるようになります。 37 {{{ 38 import os 39 os.environ['TRAC_ENV'] = "/path/to/projectenv" 40 }}} 38 41 39 [http://httpd.apache.org/docs/suexec.html Apache suEXEC] 機能を使用している場合、 [http://trac.edgewall.org/wiki/ApacheSuexec ApacheSuexec] を参照して下さい。 42 '' Or for TRAC_ENV_PARENT_DIR: '' 40 43 41 システムによっては、`trac.cgi` ファイルの shebang 行を編集して、実際に Python がインストールされているパスを指すように修正する必要がある ''かもしれません''。 Windows システム上では、 Windowsが .cgi ファイルを実行できるように設定する必要があるでしょう。 (エクスプローラ -> ツール -> フォルダオプション -> ファイルの種類 -> CGI を Python と関連付ける) 44 {{{ 45 import os 46 os.environ['TRAC_ENV_PARENT_DIR'] = "/path/to/project/parent/dir" 47 }}} 42 48 43 == 静的なリソースをマッピングする == 49 This will make Trac available at `http://yourhost.example.org/trac`. 44 50 45 このままでも Trac はスタイルシートや画像ファイルなどの静的なリソースを扱えますが、 CGI のセットアップとしては妥当な設定とは言えません。 Web サーバ自身がはるかに効率良くに直接扱うことができるドキュメントまで、 CGI スクリプトとして呼び出してしまうという結果になるからです。 51 If you are using the [http://httpd.apache.org/docs/suexec.html Apache suEXEC] feature please see [http://trac.edgewall.org/wiki/ApacheSuexec]. 46 52 47 [http://httpd.apache.org/ Apache HTTPD] のような Web サーバはリソースに対して "Alias" を設定することで仮想の URL を与え、サーバのファイルシステムのレイアウトとは異なる位置にマップすることができます。すでに CGI スクリプトに対して `ScriptAlias` を定義していますので、ファイルシステム上の静的リソースを含んだコンテンツをマッピングすることで CGI スクリプトの要求を回避します。 53 On 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). 48 54 49 Apacheの設定ファイルを再び編集して、 CGI スクリプトの `ScriptAlias` を追記したブロックより '''上に''' 以下のブロックを追記します。ファイル名とロケーションは適宜変更してください: 55 == Mapping Static Resources == 56 57 Out of the box, Trac will serve static resources such as style sheets or images itself. For a CGI setup, though, this is highly undesirable, because it results in the CGI script being invoked for documents that could be much more efficiently served by the web server directly. 58 59 Web servers such as [http://httpd.apache.org/ Apache HTTPD] allow you to create “Aliases” to resources, thereby giving them a virtual URL that doesn't necessarily bear any resemblance to the layout of the servers file system. We already used this capability above when defining a `ScriptAlias` for the CGI script, and we'll use it now to map requests to the static resources to the directory on the file system that contains them, thereby bypassing the processing of such requests by the CGI script. 60 61 Edit the Apache configuration file again and add the following snippet '''before''' the `ScriptAlias` for the CGI script , file names and locations changed to match your installation: 50 62 {{{ 51 63 Alias /trac/chrome/common /usr/share/trac/htdocs … … 56 68 }}} 57 69 58 `trac.cgi` スクリプトにどんな URL をマッピングしたとしても、 `/chrome/common` というパスでは静的リソースのロケーションを使用するようになります。 70 Note that whatever URL path you mapped the `trac.cgi` script to, the path `/chrome/common` is the path you have to append to that location to intercept requests to the static resources. 59 71 60 例えば、Trac が `/cgi-bin/trac.cgi`にマッピングされているとしたら、AliasのURLは `cgi-bin/trac.cgi/chrome/common` となります。 72 For 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`. 61 73 62 代わりに、[wiki:TracIni trac.ini] のオプションで `htdocs_location` を設定することができます: 74 Similarly, if you have static resources in a projects htdocs directory, 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): 75 76 {{{ 77 Alias /trac/chrome/site /path/to/projectenv/htdocs 78 <Directory "/path/to/projectenv/htdocs"> 79 Order allow,deny 80 Allow from all 81 </Directory> 82 }}} 83 84 Alternatively, you can set the `htdocs_location` configuration option in [wiki:TracIni trac.ini]: 63 85 {{{ 64 86 [trac] … … 66 88 }}} 67 89 68 Trac は HTML ページに静的リソースを組み込むときに、この URL を使用するようになります。もちろん、それでも、特定の URL が指定されたときに 例えば、 Web サーバーのドキュメントルートにディレクトリをコピーするなり、シンボリックリンクを張るなりして、Web サーバ経由で、 Trac が `htdocs` ディレクトリを利用できるようにしておく必要があります:90 Trac 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: 69 91 {{{ 70 92 $ ln -s /usr/share/trac/htdocs /var/www/your_site.com/htdocs/trac-htdocs 71 93 }}} 72 94 73 == 認証を追加する == 95 Note that in order to get this `htdocs` directory, you need first to extract the relevant Trac resources using the `deploy` command of TracAdmin: 96 [[TracAdminHelp(deploy)]] 74 97 75 Apache で認証を追加する最も単純な方法はパスワードファイルを作ることです。 `htpasswd` プログラムを使用してパスワードファイルを作成します: 98 99 == Adding Authentication == 100 101 The simplest way to enable authentication with Apache is to create a password file. Use the `htpasswd` program to create the password file: 76 102 {{{ 77 103 $ htpasswd -c /somewhere/trac.htpasswd admin … … 81 107 }}} 82 108 83 一番最初のユーザ以外は "-c" オプションは必要ありません:109 After the first user, you dont need the "-c" option anymore: 84 110 {{{ 85 111 $ htpasswd /somewhere/trac.htpasswd john … … 89 115 }}} 90 116 91 '' `htpasswd` についての詳細は man を見てください。''117 ''See the man page for `htpasswd` for full documentation.'' 92 118 93 ユーザを作成した後、 TracPermissions の記述通りユーザに権限を設定することができます。 119 After you've created the users, you can set their permissions using TracPermissions. 94 120 95 Apache の設定ファイルの中にパスワードファイル名を記述し、認証を有効にする必要があります:121 Now, you'll need to enable authentication against the password file in the Apache configuration: 96 122 {{{ 97 123 <Location "/trac/login"> … … 103 129 }}} 104 130 105 複数のプロジェクトを持っている場合でも、パスワードファイルはプロジェクトで共通なものを使用することができます:131 If you're hosting multiple projects you can use the same password file for all of them: 106 132 {{{ 107 133 <LocationMatch "/trac/[^/]+/login"> … … 113 139 }}} 114 140 115 より堅固なセキュリティのために、 SSL を有効にするか、少なくとも "基本認証" の代わりに "ダイジェスト認証" を使用することを推奨します。より詳しい情報については [http://httpd.apache.org/docs/2.0/ Apache HTTPD documentation] を参照して下さい。 141 For 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: 142 {{{ 143 <Location "/trac/login"> 144 LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.so 145 AuthType Digest 146 AuthName "trac" 147 AuthDigestDomain /trac 148 AuthDigestFile /somewhere/trac.htpasswd 149 Require valid-user 150 </Location> 151 }}} 152 and you'll have to create your .htpasswd file with htdigest instead of htpasswd as follows: 153 {{{ 154 # htdigest /somewhere/trac.htpasswd trac admin 155 }}} 156 where the "trac" parameter above is the same as !AuthName above ("Realm" in apache-docs). 116 157 117 158 ----