我遇到了一个令人费解的问题,当我的 Flask 应用程序需要从磁盘读取文件时,它会失败并出现以下错误:
[Mon Aug 26 22:29:48 2013] [error] [client 67.170.62.218] (2)No such file or directory: mod_wsgi (pid=15678): Unable to connect to WSGI daemon process 'flaskapp' on '/var/run/apache2/wsgi.14164.5.1.sock' after multiple attempts.
当使用 Flask 开发服务器,或运行不读取文件的应用程序时,它工作正常。
目录结构:
/flaskapp
/static
style.css
/templates
index.html
flaskapp.py
flaskapp.wsgi
config.json
烧瓶应用程序.py:
import flask
import json
app = flask.Flask(__name__)
#config = json.loads(open('config.json', 'r').read())
@app.route('/')
def index():
return "Hello World"
#return flask.render_template('index.html')
if __name__ == '__main__':
app.run(host='0.0.0.0')
烧瓶应用程序.wsgi
import sys
sys.path.append('/root/flaskapp')
from flaskapp import app as application
可用网站:
<VirtualHost *:80>
ServerName localhost
WSGIDaemonProcess flaskapp user=www-data group=www-data threads=5
WSGIScriptAlias / /root/flaskapp/flaskapp.wsgi
WSGIScriptReloading On
<Directory /root/flaskapp>
WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>