Windows

□未翻訳

□翻訳中

□翻訳完了(Omi Chiba)

■レビュー(中垣健志)

Windows

Apacheとmod_wsgi

Apache and mod_wsgi

WindowsでApacheとmod_wsgiをインストールするには異なる手順が必要になります。Python 2.5がインストールされていて、ソースから実行し、c:/web2pyにweb2pyがあることを前提に説明します。

Installing Apache, and mod_wsgi under Windows requires a different procedure. Here are assuming Python 2.5 is installed, you are running from source and web2py is located atc:/web2py.

始めに、必要なパッケージをダウンロードします:

First download the requires packages:

  • 79からApache apache_2.2.11-win32-x86-openssl-0.9.8i.msi

  • 80からmod_wsgi

    • Apache apache_2.2.11-win32-x86-openssl-0.9.8i.msi from 79

    • mod_wsgi from 80

二つ目に、apache...msiを実行し、ウィザード画面に従います。Server information画面で

Second, run apache...msi and follow the wizard screens. On the server information screen

全ての項目を入力します:

enter all requested values:

  • Network Domain: あなたのサーバの現在のまたは登録予定のDNSドメインを入力します。もしサーバの正式なDNS名がserver.mydomain.netの場合は、mydomain.netとここに入力します。

  • ServerName: あなたのサーバーの正式なDNS名。上記の例で言うと、server.mydomain.netと入力します。完全修飾ドメイン名またはショートカットでは無いweb2pyインストールのIPアドレスを入力します。詳細は82を参照。

  • Administrator's Email Address. サーバー管理者またはwebマスターのメールアドレスをここに入力します。このアドレスはデフォルトでクライアントへのエラーメッセージといっしょに表示されます。

    • Network Domain: enter the DNS domain in which your server is or will be registered in. For example, if your server's full DNS name is server.mydomain.net, you would type mydomain.net here

    • ServerName: Your server's full DNS name. From the example above, you would type server.mydomain.net here. Enter a fully qualified domain name or IP address from the web2py install, not a shortcut, for more information see 82.

    • Administrator's Email Address. Enter the server administrator's or webmaster's email address here. This address will be displayed along with error messages to the client by default.

特に必要がなければ標準インストールで最後まで続行します

Continue with a typical install to the end unless otherwise required

ウィザードは、デフォルトで、以下のフォルダにApacheをインストールします:

The wizard, by default, installed Apache in the folder:

1.

C:/Program Files/Apache Software Foundation/Apache2.2/

ここからは簡単にApache2.2と、このフォルダを呼びます。

From now on we refer to this folder simply as Apache2.2.

三つ目に、ダウンロードしたmod_wsgi.soをApache2.2/modulesにコピーします

Third, copy the downloaded mod_wsgi.so to Apache2.2/modules

Chris Traversによって書かれ、2007年12月にMicrosoftのOpen Software Labで公開されました。

written by Chris Travers, published by the Open Source Software Lab at Microsoft, December 2007.

四つ目に、server.crtserver.key証明書(前の節で説明した)を作成しApache2.2/confフォルダに入れます。cnfファイルはApache2.2/conf/openssl.cnfに入れる点に注意してください。

Fourth, create server.crt and server.key certificates (as discussed in the previous section) and place them in the folder Apache2.2/conf. Notice the cnf file is inApache2.2/conf/openssl.cnf.

五つ目に、Apache2.2/conf/httpd.confを編集し、以下の行のコメント(文字#)を外します

Fifth, edit Apache2.2/conf/httpd.conf, remove the comment mark (the # character) from the line

1.

LoadModule ssl_module modules/mod_ssl.so

全てのLoadModule行の最後に次の行を追加します

add the following line after all the other LoadModule lines

1.

LoadModule wsgi_module modules/mod_wsgi.so

"Listen 80"の記述を検索して次の行をその後に追加します

look for "Listen 80" and add this line after it

1.

Listen 443

あなたの設定値に従ってドライブレター、ポート番号、サーバ名を変更し、一番最後に次の行を追加します。

append the following lines at the end changing drive letter, port number, ServerName according to your values

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

15.

16.

17.

18.

19.

20.

21.

22.

23.

24.

25.

26.

27.

28.

29.

NameVirtualHost *:443

<VirtualHost *:443>

DocumentRoot "C:/web2py/applications"

ServerName server1

<Directory "C:/web2py">

Order allow,deny

Deny from all

</Directory>

<Location "/">

Order deny,allow

Allow from all

</Location>

<LocationMatch "^(/[\w_]*/static/.*)">

Order Allow,Deny

Allow from all

</LocationMatch>

WSGIScriptAlias / "C:/web2py/wsgihandler.py"

SSLEngine On

SSLCertificateFile conf/server.crt

SSLCertificateKeyFile conf/server.key

LogFormat "%h %l %u %t "%r" %>s %b" common

CustomLog logs/access.log common

</VirtualHost>

設定を保存し、[Start > Program > Apache HTTP Server 2.2 > Configure Apache Server > Test Configuration]を使って設定を確認します

Save and check the config using: [Start > Program > Apache HTTP Server 2.2 > Configure Apache Server > Test Configuration]

もし問題が無ければコマンド画面が開いて閉じます。これで以下からApacheを起動できます:

If there are no problems you will see a command screen open and close. Now you can start Apache:

[Start > Program > Apache HTTP Server 2.2 > Control Apache Server > Start]

できたらタスクバーモニタから起動します

or better yet start the taskbar monitor

[Start > Program > Apache HTTP Server 2.2 > Control Apache Server]

これで赤い羽根のようなタスクバーアイコンで右クリックから"Open Apache Monitor"を選択し、起動、停止、再起動を必要に応じて実行できます。

Now you can right-click on the red feather-like taskbar icon to "Open Apache Monitor" and then start, stop and restart Apache as required.

この節はJonathan Lundellによって作成されました。

This section was created by Jonathan Lundell.

Windowsサービスとして開始

Start as Windows Service

Windows service

LinuxのデーモンはWindowsではサービスと呼ばれます。web2pyサーバは簡単にWindowsサービスとしてインストール/起動/停止ができます。

What Linux calls a daemon, Windows calls a service. The web2py server can easily be installed/started/stopped as a Windows service.

web2pyをWindowsサービスとして使用するには、開始パラメータ付きで"options.py"を作成する必要があります:

In order to use web2py as a Windows service, you must create a file "options.py" with startup parameters:

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.

12.

13.

14.

import socket, os

ip = socket.gethostname()

port = 80

password = '<recycle>'

pid_filename = 'httpserver.pid'

log_filename = 'httpserver.log'

ssl_certificate = "

ssl_private_key = "

numthreads = 10

server_name = socket.gethostname()

request_queue_size = 5

timeout = 10

shutdown_timeout = 5

folder = os.getcwd()

既にモデルとして使用できる"options_std.py"というファイルがweb2pyフォルダに存在するため、"options.py"を一から作成する必要はありません。

You don't need to create "options.py" from scratch since there is already an "options_std.py" in the web2py folder that you can use as a model.

"options.py"をweb2pyをインストールしたフォルダに作成したら、web2pyを次のコマンドでサービスとして追加できます:

After creating "options.py" in the web2py installation folder, you can install web2py as a service with:

1.

python web2py.py -W install

そして次のコマンドで起動/停止できます:

and start/stop the service with:

1.

2.

python web2py.py -W start

python web2py.py -W stop