debian 6でuwsgi + python2.7 + django + nginxを使用しようとしています。コマンドでuwsgiをインストールしたpip2.7 install uwsgi
ので、python 2.7で実行されています。次のコマンドを使用して、皇帝モードで uwsgi を実行しています。
vassals フォルダーには、現時点では 1 つのアプリのみが含まれています。yaml ファイルは次のとおりです。
uwsgi:
socket: /home/uwsgi/uwsgi/uwsgi.sock
virtualenv: /opt/myproj/virt
pythonpath: /home/uwsgi/project/my_proj
pidfile: /home/uwsgi/uwsgi/uwsgi.pid
uid: uwsgi
gid: uwsgi
chmod-socket: 1
module: wsgi_app
daemonize: /home/uwsgi/uwsgi/uwsgi.log
harakiri-verbose: 1
これは、Django プロジェクト ファイルの内容です。
#! /usr/bin/python
SITE_DIR = '/home/uwsgi/project/my_proj'
import site
site.addsitedir(SITE_DIR)
import os
import sys
sys.path.append(SITE_DIR)
sys.path.append('/home/uwsgi/project/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_proj.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
ここで、起動しようとしたときの /home/uwsgi/uwsgi/uwsgi.log ファイルの結果は次のとおりです。
*** Starting uWSGI 1.0.4 (32bit) on [Fri Mar 2 19:00:46 2012] ***
compiled with version: 4.6.2 on 02 March 2012 18:03:07
current working directory: /etc/uwsgi/vassals
writing pidfile to /home/uwsgi/uwsgi/uwsgi.pid
detected binary path: /usr/local/bin/uwsgi
setgid() to 1001
setuid() to 1001
your memory page size is 4096 bytes
chmod() socket to 666 for lazy and brave users
uwsgi socket 0 bound to UNIX address /home/uwsgi/uwsgi/uwsgi.sock fd 3
Python version: 2.7.2+ (default, Dec 1 2011, 02:17:49) [GCC 4.6.2]
Set PythonHome to /opt/myproj/virt
ImportError: No module named site
*** Starting uWSGI 1.0.4 (32bit) on [Fri Mar 2 19:00:47 2012] ***
compiled with version: 4.6.2 on 02 March 2012 18:03:07
current working directory: /etc/uwsgi/vassals
writing pidfile to /home/uwsgi/uwsgi/uwsgi.pid
detected binary path: /usr/local/bin/uwsgi
setgid() to 1001
setuid() to 1001
your memory page size is 4096 bytes
chmod() socket to 666 for lazy and brave users
uwsgi socket 0 bound to UNIX address /home/uwsgi/uwsgi/uwsgi.sock fd 3
Python version: 2.7.2+ (default, Dec 1 2011, 02:17:49) [GCC 4.6.2]
Set PythonHome to /opt/myproj/virt
ImportError: No module named site
ご覧のとおり、uwsgi はサイト モジュールをインポートできないため、uwsgi はアプリの再起動を試行し続けます。そこで、yaml ファイルに no-site :1 オプションを追加してみました。その結果、Django プロジェクト ファイルに何もインポートできません...
また、プロジェクトにリンクされていないことも知っています。これは、uwsgi を python 2.6 で実行すると問題なく動作するためです...残念ながら、python2.7 で実行する必要があります...
何が起こるか分かりますか?
どうもありがとう!