我已经通过apt-get
安装了uWSGI和nginx,并将我的uwsgi-conf.ini放在/ etc / uwsgi / apps中,并将其符号链接到启用应用程序,并遵循nginx配置的相同过程
(下面列出的配置文件)
问题是我无法让uWSGI启动位于/ usr / share / nginx / www / helloflask / venv中的virtualenv
如果我添加行virtualenv = /usr/share/nginx/www/helloflask/venv
并访问服务器,我会收到502 Bad Gateway
错误?
并且virtualenv
文件中没有.ini
行,我收到此消息:
uWSGI Error
Python application not found
以下是日志文件中的几行:
Traceback (most recent call last):
File "/usr/share/nginx/www/helloflask/test.py", line 1, in <module>
from application import app
File "/usr/share/nginx/www/helloflask/application.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
- unable to load app 0 (mountpoint='xx.xx.xxx.xx|') (callable not found or import error)
xx.xx.xxx.xx {address space usage: 134094848 bytes/127MB} {rss usage: 12623872 bytes/12MB} [pid: 29848|app: -1|req: -1/6] 95.166.70.107 () {44 vars in 721 bytes} [Thu May 9 08:40:29 2013] GET /favicon.ico => generated 48 bytes in 5 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
/etc/uwsgi/apps-available/uwsgi-conf.ini
[uwsgi]
plugins = python
gid = nginx
uid = nginx
vhost = true
logdate
socket = 127.0.0.1:3031
master = true
processes = 1
harakiri = 20
limit-as = 128
memory-report
no-orphans = true
/etc/nginx/sites-available/helloflask
server {
listen 80;
server_name xx.xx.xxx.xxx;
location / {
include uwsgi_params;
uwsgi_param UWSGI_CHDIR /usr/share/nginx/www/helloflask/;
uwsgi_param UWSGI_PYHOME /user/share/nginx/www/helloflask/;
uwsgi_param UWSGI_SCRIPT test;
uwsgi_pass 127.0.0.1:3031;
}
}
答案 0 :(得分:0)
很明显,您在virtualenv中缺少必需的模块,通过以下输出:
ImportError: No module named flask
尝试将flask模块安装到virtualenv中,如果需要,也可以安装所需的任何其他模块。
source /usr/share/nginx/www/helloflask/venv/bin/activate
pip install flask