3

OSとしてFedora 20を使用して、uWSGIを介してフラスコアプリをNginxにデプロイしようとしていますが、いくつかの問題が発生しています。

次の構成ファイルがあります。

NGINX - 次の編集によるデフォルト設定:

location / { try_files $uri @yourapplication; }
location @yourapplication {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/sjudson_app_uswgi.sock;
}

uWSGI:

[uwsgi]
socket = /tmp/%n.sock
wsgi-file = sjudson_app/sjudson_app.py
callable = sjudson
master = true
chmod-socket = 666
logto = /home/server/logs/uwsgi.log

まず、実行しようとすると:

uwsgi --ini sjudson_app_uwsgi.ini

私はただ得る:

[uWSGI] getting INI configuration from sjudson_app_uwsgi.ini

無期限に。次に、コマンド ラインから直接実行すると、次のようになります。

uwsgi --socket /tmp/sjudson_app_uwsgi.sock --wsgi-file sjudson_app/sjudson_app.py --callable sjudson --master --chmod-socket=666

私は得る:

*** Starting uWSGI 2.0.3 (32bit) on [Tue Mar 25 17:58:44 2014] ***
compiled with version: 4.8.2 20131212 (Red Hat 4.8.2-7) on 25 March 2014 16:48:01
os: Linux-3.13.6-200.fc20.i686+PAE #1 SMP Fri Mar 7 17:17:53 UTC 2014
nodename: new-host-6
machine: i686
clock source: unix
detected number of CPU cores: 2
current working directory: /home/server
detected binary path: /usr/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/sjudson_app_uwsgi.sock fd 3
Python version: 2.7.5 (default, Feb 19 2014, 13:47:40)  [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x881cc40
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 127952 bytes (124 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x881cc40 pid: 1131 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1131)
spawned uWSGI worker 1 (pid: 1136, cores: 1)

しかし、サーバーに接続しようとすると、502 エラーが発生します。このstackoverflowの投稿に気付きました:Flask、nginx、およびuwsgiで同様の問題が発生しました。これに対する支持された回答は、ソケットのアクセス許可が正しくないことに関係していました。ただし、chmod-socket=666 引数があり、/tmp を確認しています。

srw-rw-rw-.  1 server server    0 Mar 25 17:53 sjudson_app_uwsgi.sock

ですから、それが問題であるようには見えません。

編集:

Nginx のエラー メッセージを含めるのを忘れていたことに気付きました。

2014/03/26 07:58:38 [crit] 792#0: *15 connect() to unix:/tmp/sjudson_app_uswgi.sock 
failed (2: No such file or directory) while connecting to upstream, client: 
173.79.242.54, server: localhost, request: "GET / HTTP/1.1", upstream: 
"uwsgi://unix:/tmp/sjudson_app_uswgi.sock:", host: "173.79.242.54"

この場合、「そのようなファイルやディレクトリはありません」とはどういう意味かわかりません。.sock ファイルが存在することは知っていますが、何を見つけるのに苦労していますか?

4

2 に答える 2

2

ほぼ同じセットアップと同じエラーメッセージがありました。それを修正するには、次のことを行う必要がありました。

  • uwsgi.ini私のファイルのソケットステートメントを次のように変更します。

    socket = 127.0.0.1:8081
    
  • 以下をファイルに追加しnginx.confます (server ステートメントの外):

    upstream uwsgi { server 127.0.0.1:8081; }
    
  • nginx.conf私のファイルの場所ステートメントを次のように変更します。

    location / { try_files $uri @uwsgi; }
    location @uwsgi {
        include uwsgi_params;
        uwsgi_pass uwsgi;
    }
    

これにより、nginx と uwsgi が通信できるようになりました。これらの手順は、http://blog.djcentric.com/setting-up-uswgi-nginx-what-you-need-to-know/から取得したものです。

于 2014-08-27T19:09:24.660 に答える
0


uwsgi_pass unix:/tmp/sjudson_app_uswgi.sock;から、nginx 構成の文字列を変更してください。 uwsgi_pass unix:///tmp/sjudson_app_uswgi.sock に
;

于 2014-06-08T00:03:26.720 に答える