在apache上部署flask app时出错

时间:2015-02-21 11:47:07

标签: python apache flask wsgi

我有一个文件manage.py,

import os
from app import create_app
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
if __name__ == '__main__':
    app.run()
在调试模式下测试时,

manage.py工作正常。但是,我无法在apache上托管它。

我的wsgi文件:start.wsgi

from manage import app as application
import sys
sys.stdout = sys.stderr

虚拟主机:

<VirtualHost *:80>
   ServerName domain.com
   WSGIDaemonProcess manage user=user group=user threads=5
   WSGIScriptAlias / /var/www/apioflifeapp/app/start.wsgi
   <Directory /var/www/apioflifeapp/app>
        Require all granted
        Options all
        AllowOverride all
        Allow from all
   </Directory>
</VirtualHost>
错误日志中的

错误

 [Sat Feb 21 10:55:47.329450 2015] [:error] [pid 25422] [client 197.226.128.204:56062]   File "/var/www/apioflifeapp/app/start.wsgi", line 1, in <module>
    [Sat Feb 21 10:55:47.329601 2015] [:error] [pid 25422] [client 197.226.128.204:56062]     from manage import app as application
    [Sat Feb 21 10:55:47.329624 2015] [:error] [pid 25422] [client 197.226.128.204:56062] ImportError: No module named manage

我不明白为什么我会收到导入错误

1 个答案:

答案 0 :(得分:0)

您需要从实际应用中导入应用名称,而不是manage。假设它是apioflifeapp,您可以在 start.wsgi 中导入以下内容:

from apioflifeapp import app as application