繁体   English   中英

为什么我会收到 500 内部服务器错误消息?

[英]Why am I getting the 500 Internal Server Error message?

我是 python、CGI 和 HTML 的新手。

我目前的项目是编写一个 Ubuntu Web 服务器。 我的一些基本表单可以正常工作,但其他脚本在我的 Web 浏览器中显示“内部服务器错误”消息。

直接从http://www.tutorialspoint.com/python/python_cgi_programming.htm中提取的以下 python 脚本应该重复您在下拉菜单中选择的选项,但我收到了“内部服务器错误”消息:

名为“dropdown.html”的 HTML 文件存储在/var/www/html

<form action = "/cgi-bin/dropdown.py" method = "post" target = "_blank">
<select name = "dropdown">
<option value = "Maths" selected>Maths</option>
<option value = "Physics">Physics</option>
</select>
<input type = "submit" value = "Submit"/>
</form>

名为“dropdown.py”的 Python 文件存储在 /usr/lib/cgi-bin 中

#!/usr/bin/python

# Import modules for CGI handling 
import cgi, cgitb 

# Create instance of FieldStorage 
form = cgi.FieldStorage() 

# Get data from fields
if form.getvalue('dropdown'):
   subject = form.getvalue('dropdown')
else:
   subject = "Not entered"

print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Dropdown Box - Sixth CGI Program</title>"
print "</head>"
print "<body>"
print "<h2> Selected Subject is %s</h2>" % subject
print "</body>"
print "</html>"

我的/var/log/apache2/error.log报告如下:

[Date] [cgi:error] [pid123:tid 123456789] [cgid:error] (2)No such file or directory: AH01241: exec of '/usr/lib/cgi-bin/dropdown.py' failed

[日期] [cgi:error] [pid123:tid 123456789] [client 192.168.xxx.xxx:57102] headers 前的脚本输出结束:dropdown.py,referer: http : //192.168.xxx.xxx/dropdown.html

知道我应该在哪里修复这个 500 内部服务器错误吗?

谢谢你。

仔细查看错误消息: /us/lib/cgi-bin/dropdown.py为什么是/us/ 你在某处打错了字。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM