Differences between revisions 1 and 5 (spanning 4 versions)
Revision 1 as of 2008-03-23 00:42:34
Size: 4623
Editor: courant
Comment: translated from mod_wsgi(2007-10-02 20:47:47) to Japanese
Revision 5 as of 2009-05-20 08:49:57
Size: 4673
Comment: Fix wiki link.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
このドキュメントは["mod_wsgi"]の翻訳です。 #language ja
このドキュメントは[[modwsgi|mod_wsgi]]の翻訳です。
Line 4: Line 5:
[[TableOfContents]] <<TableOfContents>>
Line 7: Line 8:
[http://code.google.com/p/modwsgi/ mod_wsgi]はPythonのWSGIインターフェイス(わずかに修正されたhgwebdir.cgi)をサポートするPythonアプリケーションをホストできるシンプルなApacheモジュールです。これは(mod_pythonのように)"in server"プロセス、"daemon mode" (FastCGIと同等)として動作することができます。 [[http://code.google.com/p/modwsgi/|mod_wsgi]]はPythonのWSGIインターフェイス(わずかに修正されたhgwebdir.cgi)をサポートするPythonアプリケーションをホストできるシンプルなApacheモジュールです。これは(mod_pythonのように)"in server"プロセス、"daemon mode" (FastCGIと同等)として動作することができます。
Line 9: Line 10:
むやみにドキュメントに従わないようにお願いします。少なくとも公式の [http://code.google.com/p/modwsgi/w/list mod_wsgi ドキュメンテーション] (とても素晴らしいです)、とPublishingRepositoriesをお読み下さい。 むやみにドキュメントに従わないようにお願いします。少なくとも公式の [[http://code.google.com/p/modwsgi/w/list|mod_wsgi ドキュメンテーション]] (とても素晴らしいです)、とPublishingRepositoriesをお読み下さい。
Line 113: Line 114:
----
CategoryJapanese

このドキュメントはmod_wsgiの翻訳です。

Apacheとmod_wsgiでMercurialのリポジトリを提供する

紹介

mod_wsgiはPythonのWSGIインターフェイス(わずかに修正されたhgwebdir.cgi)をサポートするPythonアプリケーションをホストできるシンプルなApacheモジュールです。これは(mod_pythonのように)"in server"プロセス、"daemon mode" (FastCGIと同等)として動作することができます。

むやみにドキュメントに従わないようにお願いします。少なくとも公式の mod_wsgi ドキュメンテーション (とても素晴らしいです)、とPublishingRepositoriesをお読み下さい。 Apache :-Dを適切に設定する方法を知っていることが求められます。

利点

  • mod_pythonもしくはfastcgiのように、古い時代に築かれたCGIよりも遙かに速いです。
  • mod_pythonよりもシンプルで、しかも速いです。
  • FastCGIよりも設定が簡単です (例えば、Apache 2.2上でMercurialリポジトリを提供するためには suexec、mod_fcgid、flupと修正されたhgweb* スクリプトも必要になります)

不利な点

  • mod_wsgiは比較的新しくテストされていません。
  • あなた自身でコンパイルすることが必要になる場合があります(すなわちOS用のパッケージがない場合)。

前提条件

次のソフトウェアが必要です(テストしたバージョンは括弧内です。他のバージョンも動作するでしょう):

  • Apache (2.2.6)
  • mod_wsgi (1.1)
  • Python (2.5.1)
  • Mercurial (0.9.4)
  • hgwebdir.wsgi

設定

mod_wsgi

あなたのオペレーティングシステム用のmod_wsgiパッケージが見つからない場合、あなた自身でコンパイルしなければなりません。

例です

$ tar xvf mod_wsgi-1.1.tar.gz
$ cd mod_wsgi-1.1
$ ./configure
$ make
$ su -c "make install"

wsgiモジュールをロードするためにhttpd.confファイルを編集して下さい:

LoadModule wsgi_module libexec/httpd/mod_wsgi.so

Apache

このサンプルのセットアップにおいて、個別のバーチャルホスト(hg.example.net)からMercurialリポジトリを提供しています。リポジトリはhtdocsディレクトリにあり、修正されたhgwebdir.cgiスクリプト(hgwebdir.wsgi)によって提供されます。

<VirtualHost *:80>
    ServerName hg.example.net
    DocumentRoot /var/www/vhosts/hg.example.net/htdocs
    ErrorLog /var/log/httpd/hg.example.net-error_log
    CustomLog /var/log/httpd/hg.example.net-access_log common

    WSGIScriptAliasMatch ^(.*) /var/www/vhosts/hg.example.net/cgi-bin/hgwebdir.wsgi$1

    # To enable "daemon" mode, uncomment following lines. (Read mod_wsgi docs for more info)
    # WSGIDaemonProcess hg.example.net user=USER group=GROUP threads=15 maximum-requests=1000
    # WSGIProcessGroup hg.example.net

    <Directory /var/www/vhosts/hg.example.net/htdocs>
        Options FollowSymlinks
        DirectoryIndex index.html

        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    <Directory /var/www/vhosts/hg.example.net/cgi-bin>
        Options ExecCGI FollowSymlinks
        AddHandler cgi-script .cgi

        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Mercurial

Merucialに付属しているhgwebdir.cgiの最後の行だけを変更する必要があります。 下記のコードはショートバージョン -hgwebdir.wsgi:

   1 #!/usr/bin/env python
   2 
   3 from mercurial.hgweb.hgwebdir_mod import hgwebdir
   4 from mercurial.hgweb.request import wsgiapplication
   5 
   6 def make_web_app():
   7     return hgwebdir("hgwebdir.config")
   8 
   9 application = wsgiapplication(make_web_app)

hgwebdir.configファイルは次のようになります:

[web]
style = gitweb

[collections]
/var/www/vhosts/hg.example.net/htdocs = /var/www/vhosts/hg.example.net/htdocs

筆者はmod_wsgiはApache上のpythonアプリケーションの未来であると思います。 本当に素晴らしく、初期の段階でありますが、より素晴らしいものになることを期待しています。

さよならmod_python/fastcgi、これらがなくても不自由をしません。


CategoryJapanese

JapaneseMod_wsgi (last edited 2009-05-20 08:49:57 by DirkjanOchtman)