我編輯這個問題後,我找到了解決方案...我需要了解爲什麼解決方案的工作,而不是我的方法?蟒蛇上的Apache - 越來越404
這可能是一個愚蠢的問題。我試圖尋找其他相關的問題......但無濟於事。
我運行的Apache/2.2.11(Ubuntu的)DAV/2 SVN/1.5.4 PHP/5.2.6-3ubuntu4.5用了Suhosin貼片的mod_python/3.3.1的Python/2.6.2
我有一個名爲test.py
#! /usr/bin/python
print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
print "hello world"
運行它作爲一個可執行的作品腳本...
/var/www$ ./test.py
Content-Type: text/html
hello world
當我運行http://localhost/test.py我得到一個404錯誤。
我在想什麼?
我用這個資源在apache上啓用python解析。 http://ubuntuforums.org/showthread.php?t=91101
從同一個線程...下面的代碼工作.. 爲什麼? #!的/ usr/bin中/ Python的
import sys
import time
def index(req):
# Following line causes error to be sent to browser
# rather than to log file (great for debug!)
sys.stderr = sys.stdout
#print "Content-type: text/html\n"
#print """
blah1 = """<html>
<head><title>A page from Python</title></head>
<body>
<h4>This page is generated by a Python script!</h4>
The current date and time is """
now = time.gmtime()
displaytime = time.strftime("%A %d %B %Y, %X",now)
#print displaytime,
blah1 += displaytime
#print """
blah1 += """
<hr>
Well House Consultants demonstration
</body>
</html>
"""
return blah1
看起來像是答案!謝謝。我會盡快接受stackoverflow允許。 – Kirby 2010-03-29 19:09:37