我正在尝试将我的一个 Flask 应用程序部署到 apache 上的 mod_wsgi,但我遇到了麻烦,因为 apache 试图解决文件系统上的一些路由:
apache 的错误日志:
[Mon Aug 06 19:18:38 2012] [error] [client ::1] File does not exist:
/srv/http/webchat/src/_publish_message, referer: http://localhost:88/webchat/chat
我说“一些路由”是因为身份验证(在“/”上)和重定向到“/chat”有效。
路由“_publish_message”通过 AJAX 像这样访问(使用 jQuery):
function publish_message(e){
e.preventDefault();
$.post('/_publish_message', {'message': "user's message taken from a text field"})
.fail(Handler.publish_error);
}
路由“_sse_stream”用作事件源的 URL。
这两个都不行!
虚拟主机配置:
<VirtualHost *:88>
ServerName webchat.dev
WSGIDaemonProcess webchat user=http group=http threads=5
WSGIScriptAlias /webchat /srv/http/webchat/src/webchat.wsgi
WSGIScriptReloading On
DocumentRoot /srv/http/webchat/src
<Directory /srv/http/webchat/src>
WSGIProcessGroup webchat
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
webchat.wsgi
文件:
import sys
sys.path.insert(0, '/srv/http/webchat/src')
from index import app as application
部署到 mod_wsgi
的基本“hello world”应用运行正常。
我的 Flask 应用程序在使用集成到 Flask 中的开发服务器运行时表现良好。
最佳答案
使用此链接遵循正确的流程。您必须使用 $SCRIPT_ROOT 变量。
关于python - 使用 mod_wsgi 部署 Flask 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11832611/