2

以下のスクリプトを 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>"

DB 接続線を削除すると正常に動作しますが、追加するimport MySQLdbと 500 内部サーバー エラーが発生します。

の出力

システムをインポート

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 です。

4

1 に答える 1

0

サーバーの問題のようです。サーバー サポートに連絡してください。

于 2013-06-21T18:03:52.013 に答える