我正在尝试使用centos在apache上运行flask app。我遵循了这个指南http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/但没有成功。当我做htop时,该服务没有在端口5000上运行。我甚至试过通过终端运行应用程序,但服务器没有响应。
myapp.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
myapp.wsgi
import sys
sys.path.insert(0, '/var/www/myapp')
from myapp import app as application
在 /etc/httpd/conf/httpd.conf
中添加了以下代码<Virtualhost *>
ServerName my.app
WSGIDaemonProcess myapp user=mapp group=mapp threads=5
WSGIScriptAlias / /var/www/myapp/myapp.wsgi
<Directory /var/www/myapp>
WSGIProcessGroup myapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Order allow,deny
Allow from all
</Directory>
</Virtualhost>
我还在 / etc / hosts 中添加了my.app(ServerName):
127.0.0.1 my.app