我有一个文件test.py
在/var/www
和我在Ubuntu 10.10上使用apache2
。我已经mod_python
安装和配置/etc/apache2/sites-available/default
为python在apache2上的404错误
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to/
#RedirectMatch ^/$ /apache2-default/
</Directory>
如果把
def index(req):
return "Test successful";
然后我得到Test successful
如果我把
#!/usr/bin/env python
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""
我得到404: Not found
错误
更多可以发现here
任何任何想法??
问候,
experimentX
如果你把什么?你的问题到底是什么? – Cameron 2011-04-11 07:11:03
@Cameron 404找不到 – 2011-04-11 07:11:37
谢谢!有一个类似的问题试图让下载的Python脚本运行(我的第一个Python遇到),这个问题让我走向了正确的方向:'print'与'def index(req):' – 2013-05-29 20:18:00