Error while deploying flask app on apache

笑着哭i 提交于 2020-01-07 08:23:15

问题


I have a file 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 is working fine when tested in debug mode. However, I'm not able to host it on apache.

my wsgi file: start.wsgi

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

virtual host:

<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>

error in error log

 [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

i'm not understanding why i'm getting the import error


回答1:


You need to import the app name from your actual application, not manage. Assuming it's apioflifeapp, you would import the following in start.wsgi instead:

from apioflifeapp import app as application


来源:https://stackoverflow.com/questions/28645391/error-while-deploying-flask-app-on-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!