2012-03-02 101 views
1

我想在debian 6上使用uwsgi + python2.7 + django + nginx。 我安裝了uwsgi命令:pip2.7 install uwsgi,所以它使用python 2.7運行。 我跑在皇帝模式uwsgi用命令: uwsgi --emperor的/ etc/uwsgi /附庸/ -d /var/log/uwsgi.log --pidfile /var/run/uwsgi.piduwsgi + python2.7無法導入任何東西

vassals文件夾目前只包含一個應用程序。下面是它的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項目文件中導入任何東西......

我也知道它沒有鏈接到項目,因爲如果我用python 2.6運行uwsgi,它就會正常工作......不幸的是,我必須運行python2.7 ...

你知道會發生什麼嗎?

非常感謝!

回答

3

請確保您的virtualenv是爲python2.7構建的,否則無法使用。

它必須包含/opt/myproj/virt/lib/python2.7目錄

+1

現在它已被調試。 問題是我用來安裝virtualenv的腳本被刪除。 它用pip而不是pip-2.7安裝python工具。 – user1187797 2012-03-03 10:45:40

+0

對不起,這個愚蠢的問題,但...我怎麼關閉票? – user1187797 2012-03-03 10:46:55

+0

@ user1187797您將最喜歡的答案投票爲最佳答案。 – dragon 2012-05-25 03:13:34