python - Apache Python 内部服务器错误 500
问题描述
我在 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
解决方案
我找到了答案,请运行 dos2unix 命令将您的 .py 文件转换为不包含无效字符的文件。
推荐阅读
- python - Python,正则表达式:查找并替换“yyyy”的所有实例,除非在句点前面
- php - 致命错误:未捕获的错误:调用未定义的方法 stdClass::nameoffunction() 以前工作的页面出错
- elm - 榆树联合子集
- python - 给定一个字符串列表,在另一个大字符串列表中找到每个字符串最接近的匹配项(编辑距离)
- java - Spring Boot 2 上的 Java BeanDefinitionStoreException
- php - 从命令行设置全局 php 环境变量?
- javascript - 仅接受使用 materialize 列出的选项的自动完成
- azure-cosmosdb - Cosmos db 用户 ID/电子邮件作为分区键
- java - Generating a new java class by writing java program in another java class
- python - 我创建了许多具有相同名称的精灵,当对所有精灵进行任何操作时,它只会影响最后创建的精灵