【问题标题】:Apache Python internal server error 500Apache Python 内部服务器错误 500
【发布时间】:2018-11-14 13:16:36
【问题描述】:

我在 rhel 7 上有 Apache 2.4.6、python 2.7

我的 html 表单 trial1 为

<form action = "/cgi-bin/upload3.py" method = "post">
First Name: <input type = "text" name = "first_name"><br />
Last Name: <input type = "text" name = "last_name" />

<input type = "submit" value = "Submit" />
</form>

我的 python 脚本 upload3.py 为:

#!/usr/bin/python
import cgi, cgitb 
form = cgi.FieldStorage() 
first_name = form.getvalue('first_name')
last_name  = form.getvalue('last_name')
print "Content-type:text/html"
print "<html>"
print "<head>"
print "<title>Hello - Second CGI Program</title>"
print "</head>"
print "<body>"
print "<h2>Hello %s %s</h2>" % (first_name, last_name)
print "</body>"
print "</html>"

在将表单输入传递给 python 时,我面临内部服务器错误 500,错误日志也没有得到更新。在更新之前它显示:

[Mon Jun 04 19:50:23.883970 2018] [cgi:error] [pid 2921] [client 10.19.0.153:63063] AH01215: (2)No such file or directory: exec of '/var/www/cgi-bin/upload3.py' failed, referer: http://10.210.58.218/trial1.html
[Mon Jun 04 19:50:23.884649 2018] [cgi:error] [pid 2921] [client 10.19.0.153:63063] End of script output before headers: upload3.py, referer: http://10.210.58.218/trial1.html

【问题讨论】:

  • 你能检查 /var/www/cgi-bin/ 位置中的 upload3.py 文件吗?
  • 我做了它可用

标签: python html apache


【解决方案1】:

我找到了答案,请运行 dos2unix 命令将您的 .py 文件转换为不包含无效字符的文件。

【讨论】:

    猜你喜欢
    • 2015-11-22
    • 2015-02-12
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 2016-02-16
    • 1970-01-01
    • 2016-10-28
    • 2011-10-09
    相关资源
    最近更新 更多