现在我有我的应用程序,该应用程序位于名为"/rg/server.py"的文件中,如下所示:app=Flask(__name__)# all app routes...if __name__ == '__main__': app.run( debug=True, host="127.0.0.1", port=80 )比我有一个wsgi文件为"/rg/wsgi/minerva.wsgi" import syssys.path.insert(0, /rg)from server import app as minerva最后,我在"etc/apach2/sites-available/minerva.com"中有一个apache配置文件:<VirtualHost *> ServerName minerva.test WSGIDaemonProcess minerva threads=10 WSGIScriptAlias / /rg/wsgi/minerva.wsgi <Directory /rg> WSGIProcessGroup minerva WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory></VirtualHost>然后,我使用成功的a2ensite minerva.com更新了apache.然后我说服了Apache,没有任何错误.但是我不能以任何方式访问minerva.test ...如果我输入apache2ctl -S,它会列出minerva.test我不知道出了什么问题...系统信息:操作系统:Debian 64bitpython 2.7 解决方案对于mod_wsgi,WSGI应用程序入口点必须称为"application".你有:from server import app as minerva应该是:from server import app as application您甚至还没走那么远,否则一行:sys.path.insert(0, /rg)会给出语法错误.再往前走,而不是:<VirtualHost *>您应该拥有:<VirtualHost *:80>最后,如果'minerva.test'实际上不是可解析的主机,那么您将无所适从.因此,使用在浏览器中使用的实际URL填写您的问题,并指出本地主机文件中是否甚至列出了"minerva.test".I have a small web application that I have built using Flask and python. With the internal server that I used for developing everything runs fine. However now I want to use apache to start using it. But it doesn`t work. Keep in mind that I have never worked with apache or web based stuff before.I used this guide as my starting point:http://flask.pocoo.org/docs/deploying/mod_wsgi/right now I have my application which is in the file called "/rg/server.py" and looks like this:app=Flask(__name__)# all app routes...if __name__ == '__main__': app.run( debug=True, host="127.0.0.1", port=80 )than I have a wsgi file as "/rg/wsgi/minerva.wsgi"import syssys.path.insert(0, /rg)from server import app as minervaand finally I have an apache config file in "etc/apach2/sites-available/minerva.com":<VirtualHost *> ServerName minerva.test WSGIDaemonProcess minerva threads=10 WSGIScriptAlias / /rg/wsgi/minerva.wsgi <Directory /rg> WSGIProcessGroup minerva WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory></VirtualHost>Then I updated apache with a2ensite minerva.com which succeded. Then I releaded Apache and no errors. However I cannot acces minerva.test in any way...If I type in apache2ctl -S it does list minerva.testI have no idea what is going wrong...system information:OS: debian 64bitpython 2.7 解决方案 The WSGI application entry point must be called 'application' for mod_wsgi. You have:from server import app as minervaIt should be:from server import app as applicationYou aren't even getting that far though, else the line:sys.path.insert(0, /rg)would give a syntax error.Going back further, instead of:<VirtualHost *>you should have:<VirtualHost *:80>and finally, if 'minerva.test' isn't actually a resolvable host, you will not get anywhere.So fill out your question with the actual URL you are using in the browser and also indicate whether 'minerva.test' is even listed in local hosts file. 这篇关于使用Flask和wsgi进行Apache设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-27 09:08