Httpd配置错误"没有模块名称web"

时间:2014-01-27 04:06:23

标签: python apache web.py

我计划将httpd DocumentRoot更改为/home/webpy。所以我修改了/etc/httpd/conf/httpd.conf

DocumentRoot "/home/webpy/"

以下内容,我根据official document配置httpd.conf 这是详细信息:

WSGIScriptAlias /web /home/webpy/index.py/
LoadModule wsgi_module modules/mod_wsgi.so
Alias /web/static /home/webpy/static/
AddType text/html .py

<Directory /home/webpy>
    Order allow,deny
    Allow from all    
</Directory>

但是当我访问http://10.0.3.129/web时,它会发生内部错误。我已经安装了web.py。 这是日志细节:

[Mon Jan 27 11:53:55 2014] [error] [client 10.0.3.129] mod_wsgi (pid=7046): Target WSGI  script '/home/webpy/index.py' cannot be loaded as Python module.
[Mon Jan 27 11:53:55 2014] [error] [client 10.0.3.129] mod_wsgi (pid=7046): Exception occurred processing WSGI script '/home/webpy/index.py'.
[Mon Jan 27 11:53:55 2014] [error] [client 10.0.3.129] Traceback (most recent call last):
[Mon Jan 27 11:53:55 2014] [error] [client 10.0.3.129]   File "/home/webpy/index.py", line 3, in <module>
[Mon Jan 27 11:53:55 2014] [error] [client 10.0.3.129]     import web
[Mon Jan 27 11:53:55 2014] [error] [client 10.0.3.129] ImportError: No module named web

出了什么问题? python path没有任何关系。这是index.py:

#-*- coding:utf-8 -*-

import os
import sys

abspath = os.path.dirname(__file__)
sys.path.append(abspath)
os.chdir(abspath)

import web

urls = (
'/','WebpyTest'
)

def my_processor(handler):
result = handler()
return result

class WebpyTest(object):

    def __init__(self):
        self.app_root = os.path.dirname(__file__)
        self.templates_root = os.path.join(self.app_root, 'templates') 
        self.render = web.template.render(self.templates_root)

    def GET(self): 
        return None



    def POST(self):
        return None


app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()

有人可以帮助我吗?非常感谢!

0 个答案:

没有答案