【发布时间】:2009-04-01 15:11:15
【问题描述】:
我正在尝试让 mod-python 与 apache2 一起工作,但没有任何成功。我已经遵循了一些让 mod-python 工作的教程,但我看不出我做错了什么。
当我访问http://site.example.com/cgi-bin/test.py 时,我实际上得到了我的 404 页面! (而如果文件真的不存在,我会得到 403 禁止)
这是我的设置:
在 /etc/apache2/sites-enabled/ 中有以我的每个域命名的配置文件。在the site.example.com file 中,我已将此添加到用户指令部分:
# Begin user directives <--
<Directory /home/default/site.example.com/user/htdocs/cgi-bin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</Directory>
# --> End user directives
完整文件here,其中包括以下行:
EDIT 添加 test.py 的内容:
#!/usr/bin/python
print "Content-type: text/html"
print
print 'hello world'
#print 1/0
如上图,我得到一个404 /python/test.py was not found on this server。
但是如果我取消注释我得到的最后一行:
Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
result = object(req)
File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 98, in handler
path=[path])
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 457, in import_module
module = imp.load_module(mname, f, p, d)
File "/home/default/site.example.co.uk/user/htdocs/python/test.py", line 5, in ?
print 1/0
ZeroDivisionError: integer division or modulo by zero
这个回溯看起来正确吗?顺便开启cgitb没有效果。
我可以添加任何其他信息来帮助诊断吗?
【问题讨论】:
标签: apache2 mod-python cgi-bin