简体   繁体   English

使用mod_wsgi在Apache背后设置pico

[英]Setting up pico behind apache using mod_wsgi

I'm trying to use pico for a small project. 我正在尝试将pico用于一个小项目。 It works fine using the standard server shipped with pico but I'm unable to get it running on apache. 使用pico随附的标准服务器,它可以正常工作,但是我无法使其在apache上运行。

I've already gone through this guide and everything went smoothly so I know that mod_wsgi is configured correctly. 我已经阅读了指南,一切都进行得很顺利,所以我知道mod_wsgi配置正确。

I followed the WSGI set up instructions on the pico wiki to the letter but this is the error I get when trying to access my page: 我遵循了pico Wiki上有关这封信的WSGI设置说明,但这是尝试访问页面时遇到的错误:

GET localhost/pico/client.js 404 (NOT FOUND) GET localhost / pico / client.js 404(未找到)

Which results in the "pico is not defined" reference error. 从而导致“未定义pico”引用错误。

All my test code is located in /var/www/ (I've tried other locations as well) 我所有的测试代码都位于/ var / www /中(我也尝试过其他位置)

pico was installed using pip and is located in /usr/local/lib/python2.7/dist-packages/pico (I even tried modifying the access permission of the files in pico). pico是使用pip安装的,位于/usr/local/lib/python2.7/dist-packages/pico(我什至尝试修改pico中文件的访问权限)。

pico.wsgi is located in /var/www/pico/pico.wsgi pico.wsgi位于/var/www/pico/pico.wsgi

My 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

I might not be using my "path" variable as intended but I don't see what else it should reference. 我可能未按预期使用“ path”变量,但看不到它还应引用什么。

My httpd.conf: 我的httpd.conf:

WSGIScriptAlias /pico /var/www/pico/pico.wsgi

    <Directory /var/www/>
    Order allow,deny
    Allow from all
    </Directory>

My index.html (located in /var/www/): 我的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>

And finally, sys.path printed from pico.wsgi: 最后,从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']

I'm new to apache and wsgi in general so there might be something obvious I'm missing. 我对apache和wsgi还是陌生的,所以我可能会缺少一些明显的东西。

I think the WSGIScriptAlias line should be 我认为WSGIScriptAlias行应该是

WSGIScriptAlias /pico /var/www/pico/pico.wsgi/pico

Note the /pico after the .wsgi 注意.wsgi之后的/pico

This became necessary after an update to pico a while ago but I forgot to update the wiki . 不久前更新了pico之后,这变得很有必要,但是我忘了更新wiki Apologies for that. 对此表示歉意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM