繁体   English   中英

运行 Python - 500 内部服务错误

[英]Running Python - 500 Internal Service Error

我有以下代码(test.cgi):

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

该文件是 CHMOD 777,它所在的目录也是如此。

我收到以下错误日志

[Sun Apr 12 02:24:46.395628 2015] [cgi:error] [pid 3574:tid 34479148032] [client 172.17.240.2:19716] AH01215: env: python\r: : /fs5a/cheerupper/public/scripts/test.cgi
[Sun Apr 12 02:24:46.396715 2015] [cgi:error] [pid 3574:tid 34479148032] [client 172.17.240.2:19716] AH01215: No such file or directory: /fs5a/cheerupper/public/scripts/test.cgi
[Sun Apr 12 02:24:46.397453 2015] [cgi:error] [pid 3574:tid 34479148032] [client 172.17.240.2:19716] End of script output before headers: test.cgi

当我尝试在浏览器中运行时,出现 500 内部服务错误。 我可以在通过命令行通过 SSH 连接到服务器时运行。 我曾在 Namecheap 服务器上尝试过,现在正在 NearlyFreeSpeech.net 上尝试获得相同的结果。

看起来您的文件是用 Windows 换行符保存的。 您的编辑器应该可以选择将其更改为您的服务器所期望的 Unix 换行符。

简短的 CGI 程序:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

暂无
暂无

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

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