我正在尝试将pico用于一个小项目。它使用pico附带的标准服务器工作正常,但我无法让它在apache上运行。
我已经通过this指南,一切顺利,所以我知道mod_wsgi配置正确。
我按照pico wiki上的WSGI设置说明写了这封信,但这是我在尝试访问我的页面时遇到的错误:
获取localhost / pico / client.js 404(未找到)
导致“pico未定义”参考错误。
我的所有测试代码都位于/ var / www /(我也尝试了其他位置)
pico是使用pip安装的,位于/usr/local/lib/python2.7/dist-packages/pico(我甚至尝试修改pico中文件的访问权限)。
pico.wsgi位于/var/www/pico/pico.wsgi
我的pico.wsgi:
import pico.server
import sys
sys.stdout = sys.stderr # sys.stdout access restricted by mod_wsgi
path = '/var/www/' # the modules you want to be usable by Pico
if path not in sys.path:
sys.path.insert(0, path)
# Set the WSGI application handler
application = pico.server.wsgi_app
我可能没有按预期使用我的“路径”变量,但我看不出它应该引用什么。
我的httpd.conf:
WSGIScriptAlias /pico /var/www/pico/pico.wsgi
<Directory /var/www/>
Order allow,deny
Allow from all
</Directory>
我的index.html(位于/ var / www /):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="http://d3js.org/d3.v3.js"></script>
<script src="/pico/client.js"></script>
<script src="picoTest.js"></script>
</head>
<body>
<div id="container">
<div id="toolbar"></div>
<div id="graph"></div>
</div>
</body>
</html>
最后,从pico.wsgi打印出sys.path:
['/var/www/', '/var/www/pico', '/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/virtualenv-1.9.1-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/distribute-0.6.35-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/numpy-1.7.0-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/gevent_websocket-0.3.6-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/daemon-1.0-py2.7.egg', '/home/kjartan/work/risk/maynard', '/var/www/pico', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
我一般都是apache和wsgi的新手,所以可能会有一些我不知道的东西。
答案 0 :(得分:0)
我认为WSGIScriptAlias行应该是
WSGIScriptAlias /pico /var/www/pico/pico.wsgi/pico
请注意/pico
.wsgi
在更新到pico之后这变得有必要,但我忘了更新wiki。为此道歉。