首页 文章

Apache 2.4(32位)目标WSGI脚本不能作为Python模块加载 . web.py

提问于
浏览
0

os:widows 2012r2

网络服务器:apache 2.4.23(32bit)

python:2.7.12

web框架:web.py 0.38

mod_wsgi:mod_wsgi-4.4.23 ap24vc9-cp27-cp27m-win32

我给apache服务器系统权限,因此可以排除权限的原因 .

整个过程是:Http-> Apache 2.4-> mod_wsgi-> web.py

wsgi.conf:

WSGIScriptAlias /“C:/Apache24/htdocs/test.py/”

别名/静态“C:/ Apache24 / htdocs / static /”AddType text / html .py

要求全部拒绝要求全部授予

=================================================

test.py:

编码:UTF-8

导入网站

urls =('/ . *','你好',)

class hello:def GET(self):返回“Hello,world” .

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

application = app.wsgifunc()

=================================================

然后,它的工作原理!我打开IE并输入url:localhost:80,页面显示:Hello,world .

基于以上所述,我更改了wsgi.conf的代码:

=================================================

WSGIScriptAlias /“C:/Apache24/htdocs/code.py/”

别名/静态“C:/ Apache24 / htdocs / static /”AddType text / html .py

要求全部拒绝要求全部授予

=================================================

和code.py:

编码:utf-8

从config.url导入网址导入网页

app = web.application(urls,globals())

application = app.wsgifunc()

=================================================

然后apache仍然有效,

但是error.log显示:“目标WSGI脚本'C:/Apache24/htdocs/code.py'无法作为Python模块加载 . ”

并且URL:localhost:80无法正常工作,显示:“500 Internal Server Error”

任何人都可以告诉如何解决问题?非常感谢 .

error.log:

[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] mod_wsgi(pid = 3780):目标WSGI脚本'C:/ Apache24 / htdocs / code .py'无法作为Python模块加载 .

[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] mod_wsgi(pid = 3780):处理WSGI脚本'C:/ Apache24 / htdocs时发生异常/code.py” .

[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] Traceback(最近一次调用最后一次):

[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159]文件“C:/Apache24/htdocs/code.py”,第5行,

[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159]来自config.url导入网址

[Thu Aug 25 02:05:43.687446 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61159] ImportError:没有名为config.url的模块

[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] mod_wsgi(pid = 3780):目标WSGI脚本'C:/ Apache24 / htdocs / code .py'无法作为Python模块加载 . ,referer:192.168.1.146

[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] mod_wsgi(pid = 3780):处理WSGI脚本'C:/ Apache24 / htdocs时发生异常/code.py' . ,referer:192.168.1.146

[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] Traceback(最近一次调用最后一次):,referer:192.168.1.146

[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160]文件“C:/Apache24/htdocs/code.py”,第5行,在,参考文献:192.168.1.146

[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160]来自config.url import urls,referer:192.168.1.146

[Thu Aug 25 02:05:43.859495 2016] [wsgi:error] [pid 3780:tid 1248] [client 192.168.1.107:61160] ImportError:没有名为config.url的模块,referer:192.168.1.146

1 回答

  • 0

    包含 config 包/模块的目录不在Python模块搜索路径中 . 您需要使用 WSGIPythonPath 指令来告诉由mod_wsgi运行的Python解释器 .

相关问题