我在cgi-bin中编写以下脚本,而如果我通过输入URL从浏览器运行此脚本,则脚本会出现500 internal server
错误。
#!/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
操作系统是Redhat。
答案 0 :(得分:0)
看起来像服务器问题。联系您的服务器支持