python virtualenv(包装器)+ uwsgi + nginx(再次)

python virtualenv(wrapper) + uwsgi + nginx (YET AGAIN)

好的,我知道那里有很多 virtualenv + uwsgi + nginx 文章,我已经阅读了大约 50 篇(我 没有 完整阅读 uWSGI 文档) .

我的问题:

为什么 none 这些选项实际上 activate 我要求它做的 virtualenv?

[uwsgi]
home = <path to python3 venv>
venv = <path to python3 venv>
virtualenv = <path to python3 venv>

但是我尝试了,我无法从默认的 python2.7 启动 uwsgi(已安装并正在运行),并且无法读取 uwsgi.iniactivate virtualenv,启动我的 django 项目。 uwsgi 也安装在 virtualenv 上。

所有其他内容(用户、组和权限)都已准备就绪,并且可以正常工作。

失败:从 开始 virtualenv 活动:

$> uwsgi --ini uwsgi.ini
[uWSGI] getting INI configuration from uwsgi.ini
*** Starting uWSGI 2.0.9 (64bit) on [Fri Feb 13 14:48:03 2015] ***
compiled with version: 4.8.2 on 20 January 2015 14:01:30
os: Linux-3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014
nodename: intergate.io
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /www/django/intergate_io
writing pidfile to /www/django/intergate_io/run/project-master.pid
detected binary path: /usr/local/bin/uwsgi
chdir() to /www/django/intergate_io
your processes number limit is 3750
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: enabled
uwsgi socket 0 bound to UNIX address /www/django/intergate_io/run/socket.sock fd 3
Python version: 2.7.6 (default, Mar 22 2014, 23:03:41)  [GCC 4.8.2]
Set PythonHome to /opt/vEnvs3/django/
ImportError: No module named site

成功:激活 virtualenv,并开始:

$> workon django
(django) $> uwsgi --ini uwsgi.ini
*** Starting uWSGI 2.0.9 (64bit) on [Fri Feb 13 14:49:42 2015] ***
compiled with version: 4.8.2 on 13 February 2015 06:07:54
os: Linux-3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014
nodename: intergate.io
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /www/django/intergate_io
writing pidfile to /www/django/intergate_io/run/project-master.pid
detected binary path: /opt/vEnvs3/django/bin/uwsgi
chdir() to /www/django/intergate_io
your processes number limit is 3750
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: enabled
uwsgi socket 0 bound to UNIX address /www/django/intergate_io/run/socket.sock fd 3
Python version: 3.4.0 (default, Apr 11 2014, 13:08:40)  [GCC 4.8.2]
Set PythonHome to /opt/vEnvs3/django/
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xe7fc00
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 218280 bytes (213 KB) for 2 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xe7fc00 pid: 2682 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2682)
spawned uWSGI worker 1 (pid: 2683, cores: 1)
spawned uWSGI worker 2 (pid: 2684, cores: 1)

在第一种情况下,您似乎正在启动某种全局(可能与 sudo pip 一起安装)uwsgi,如输出所示:

detected binary path: /usr/local/bin/uwsgi

它可能缺少 python3 插件来正确切换环境,一般来说,我发现从 virtualenv 使用 uwsgi 总是更简单——它只是更频繁地工作。真的,不要费心尝试在系统范围内工作,使用你自己的。您将需要在另一个配置中添加完整路径,但这几乎不是问题。只需启动 /path/to/your/venv/bin/uwsgi 而不是 uwsgi.