2
我在cgi-bin中編寫下面的腳本,而如果我通過輸入URL從瀏覽器運行此腳本,那麼腳本會給出500 internal server
錯誤。CGI python中的MySQLDB導入錯誤腳本
#!/usr/bin/python
import MySQLdb
import cgi
print "Content-type: text/html"
print
print "<html>"
print "<head>"
print "<title>Listing</title>"
print "</head>"
print "<body>"
print "<h2>listing</h2>"
db = MySQLdb.connect(host="localhost", user="user", passwd="password", db="DB_name")
cur = db.cursor()
cur.execute("select * from table")
rows = cur.fetchall()
for row in rows:
print row[0]
print "</body>"
print "</html>"
如果我刪除數據庫連接線那麼它工作正常,但如果我只是添加import MySQLdb
然後我得到500內部服務器錯誤。
出放
進口SYS
for p in sys.path:
print p + "<br/>"
/home/database/public_html/cgi-bin
/usr/lib64/python26.zip
/usr/lib64/python2.6
/usr/lib64/python2.6/plat-linux2
/usr/lib64/python2.6/lib-tk
/usr/lib64/python2.6/lib-old
/usr/lib64/python2.6/lib-dynload
/usr/lib64/python2.6/site-packages
/usr/lib64/python2.6/site-packages/gtk-2.0
/usr/lib/python2.6/site-packages
操作系統是紅帽。
您是否嘗試過從控制檯運行腳本並查看它給出的錯誤? – jabaldonedo 2013-04-25 18:02:41
它在(大概)Apache錯誤日誌中說了什麼? – 2013-04-25 18:05:30
@DanielRoseman它的現場服務器,我看不到Apache錯誤日誌,任何建議,我可以看到日誌文件? – Noor 2013-04-25 18:11:06