1

我已经安装了 uWSGI 和 nginx apt-get,并将我的 uwsgi-conf.ini 放在 /etc/uwsgi/apps-available 中,并将其符号链接到启用应用程序,并对 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;
  }
}
4

1 回答 1

0

通过以下输出,很明显您在 virtualenv 中缺少必需的模块:

ImportError: No module named flask

尝试将flask模块安装到您的virtualenv中,如果需要,也安装任何其他需要的模块。

source /usr/share/nginx/www/helloflask/venv/bin/activate
pip install flask
于 2013-06-15T03:42:44.930 回答