4

ローカル仮想環境で最も単純なピラミッド アプリを正常に実行できました。私は現在、このチュートリアルに取り組んでいますが、このようなものをいじるために使用する個人のホスティングサイトで実行することにより、さらに一歩進めようとしています。

私の質問はです。パラメータとして何を渡し、make_server(host, port, app)実行されているかどうかを確認するにはどの URL にアクセスすればよいですか? 簡単な質問であることはわかっています。この種の作業に慣れていないだけで、ドキュメントは役に立ちません。

ボーナスポイント:

この種の Web アプリケーションに関して、これをローカル仮想環境で実行する場合と適切なホスティングで実行する場合の違いは何ですか?

重要な編集:私のプロバイダーは bluehost であり、専用の IP を持っていないため、自分のポートを開くことは許可されていません。

4

3 に答える 3

1

makeserverテスト展開に使用します。この場合、次のように小さな runserver-Script をラップすることがよくあります (チュートリアルでも指摘されているように)。

#!/bin/env python
from wsgiref.simple_server import make_server
from yourapp.core import app # whereever your wsgi app lives

if __name__ == '__main__':
     server = make_server('0.0.0.0', 6547, app)
     print ('Starting up server on http://localhost:6547')
     server.serve_forever()

Apache にデプロイする場合は、mod_wsgi モジュールが必要です。nginx または lighthttpd をサポートするホスティング サービスを利用することをお勧めします。WSGI アプリケーションは、uwsgi モジュールを virtualenv と組み合わせて使用​​することで、非常に便利にデプロイできます。

ホスティング事業者がポートを開くことを許可していない場合は、uwsgi を構成して unix ソケットを使用できます。

uwsgi + nginx の背後に Django を一度デプロイする方法を説明するブログ記事を書きました。 -django-behind-nginx-with-uwsgi-and-virtualenv/

注: make_server にフィードするのと同じアプリ オブジェクトを使用して、uwsgi はそのワーカー プロセスを開始し、ソケットを開きます。

uwsgi のサンプル構成 (テストされていませんが、私のブログ投稿から抜粋):

# uwsgi.ini
[uwsgi]
# path to where you put your project code
chdir=/home/project/project

# if the app object resides in core.py
module=core:app

# this switch tells uwsgi to spawn a master process,
# that will dynamically spawn new child processes for
# server requests
master=True
# uwsgi stores the pid of your master process here
pidfile=/home/project/master.pid
vacuum=True
# path to your virtual environment, you should be using virtualenv
home=/home/project/env/
# path to log file
daemonize=/home/project/log
# this is where you need to point nginx to,
# if you chose to put this in project home make
# sure the home dir is readable and executable by
# nginx
socket=/tmp/uwsgi.sock

nginx のサンプル構成:

server {
    listen       80;
    server_name  yourserver.example.org;

    location / {
        uwsgi_pass unix:///tmp/uwsgi.sock;
        include uwsgi_params;
    }
}
于 2013-07-05T14:56:05.070 に答える