通过Nginx服务Flask的问题

2024-04-27 03:32:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我不能通过nginx提供烧瓶。我看了一下日志,上面写着:

Traceback (most recent call last):
  File "/var/www/site.me/server.py", line 1, in <module>
    from flask import Flask
ImportError: No module named flask
Sun Jun  8 09:35:30 2014 - unable to load app 0 (mountpoint='') (callable not found or import error)
Sun Jun  8 09:35:30 2014 - *** no app loaded. going in full dynamic mode ***
Sun Jun  8 09:35:30 2014 - *** uWSGI is running in multiple interpreter mode ***
Sun Jun  8 09:35:30 2014 - spawned uWSGI master process (pid: 2176)
Sun Jun  8 09:35:30 2014 - spawned uWSGI worker 1 (pid: 2180, cores: 1)
Sun Jun  8 09:35:30 2014 - spawned uWSGI worker 2 (pid: 2181, cores: 1)

但是,在虚拟环境中,我确保安装了flask。 这是我的nginx配置文件。你知道吗

server {
    listen 80;
    root /var/www/site;

    index index.html index.htm;
    error_log /root/Documents/site;
    rewrite_log on;
    server_name www.site.me;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/site.sock;
        uwsgi_param UWSGI_CHDIR /var/www/site/env;
        uwsgi_param UWSGI_PYHOME /var/www/site/env;
        uwsgi_param UWSGI_MODULE server;
        uwsgi_param UWSGI_CALLABLE app;
    }
}

这是我对uwsgi的配置。你知道吗

[uwsgi]
vhost = true
socket = /tmp/site.sock
venv = /var/www/site.sock/.env
chdir = /var/www/site.me/
module = server
callable = app
no-site= true

我将非常感谢任何帮助。你知道吗


Tags: inappflaskserverparamvarwwwsite