1

シンプルな Django プロジェクトをデプロイしようとしていますが、いつも失敗します。ここの指示に従っています。

使用するpython manage.py runserver 0.0.0.0:8000と、サイトが実行されていることがわかります。

ここに画像の説明を入力

virtualenv に uWSGI をインストールしました:

pip install uwsgi

そして書いたtest.py

# test.py
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"] # python3
    #return ["Hello World"] # python2

走っているuwsgi --http :8000 --wsgi-file test.pyと見える

ここに画像の説明を入力

次に、Nginxを起動してインストールしました:

sudo apt-get install nginx
sudo /etc/init.d/nginx start

私は見えます

ここに画像の説明を入力

そして書いたmysite_nginx.conf

upstream django {
    # server unix:///path/to/your/mysite/mysite.sock; # for a file socket
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8000;
    # the domain name it will serve for
    server_name 10.211.55.21; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    #location /media  {
    #     alias /path/to/your/mysite/media;  # your Django project's media files - amend as required
    #}

    #location /static {
     #   alias /path/to/your/mysite/static; # your Django project's static files - amend as required
    #}

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/parallels/books/mysite/uwsgi_params; # the uwsgi_params file you installed
    }
}

これは単純なサイトなので、メディアと静的パスをコメントアウトしましたuwsgi_params

uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;
uwsgi_param  REQUEST_SCHEME     $scheme;
uwsgi_param  HTTPS              $https if_not_empty;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;

ディレクトリ:

ここに画像の説明を入力

そして実行します:

sudo ln -s ~/home/parallels/books/mysite/mysite_nginx.conf
/etc/nginx/sites-enabled/

mysite_nginx.conf私は内で見ることができます/etc/nginx/sites-enabled/

ここに画像の説明を入力

そして実行します:

sudo /etc/init.d/nginx restart
uwsgi --socket :8001 --wsgi-file test.py

Web ブラウザーに何も表示されません。

ここに画像の説明を入力

Django サイトをデプロイしようとするたびに、ソケット部分が失敗する理由はわかりません。

4

1 に答える 1