复杂的 cgi 脚本可以工作,但 test.cgi 不能
我在同一个 cgi-bin 文件夹中有两个 cgi 文件。一个复杂的 300hundread 行脚本可以正常工作,但是当涉及到这个简单的 cgi 脚本时:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "<html><head>";
print "<title>CGI Test</title>";
print "</head>";
print "<body><h1>I just wrote a web page using Perl!</h1>";
print "</body></html>";
网页将返回 500 内部服务器错误...
为什么?:(
编辑: 好的,问题在一台服务器上解决了,cgi 工作正常。但是...
现在我试图让 cgi 脚本在另一台服务器上工作,似乎无论我做什么,我都会不断收到“内部服务器错误”消息,并且错误日志中没有任何内容。 有什么建议吗?
I have two cgi files in the same cgi-bin folder. One complex 300hundread lines script works fine, but when it comes to this simple cgi-script:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "<html><head>";
print "<title>CGI Test</title>";
print "</head>";
print "<body><h1>I just wrote a web page using Perl!</h1>";
print "</body></html>";
the web page will return an 500 Internal Server Error...
Why?:(
EDIT:
Ok, the problem was solved on one server, the cgi works fine. But...
Now I'm trying to make the cgi-scripts work on another server and it seems that no matter what I do I keep getting the "Internal server error" message and nothing in the error log.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我想到两种可能性:
test.cgi
是一个特殊名称,由服务器配置重定向到其他地方您可以运行
test.cgi
从命令行?Two possibilities come to mind:
test.cgi
is a special name that is redirected elsewhere by the server configurationCan you run
test.cgi
from the command line?检查 Web 服务器日志以获取详细信息。
在大多数情况下,这是一个权限问题,不仅是执行此脚本的权限,而且例如出于安全原因,某些 Web 服务器默认拒绝执行具有 777 或任何其他可写权限的脚本。
尝试为该文件设置 644 权限。
Check Web-server logs for details.
In most cases its a permissions issues, not only the permission to execute this script but for example some web-servers by default refuse to execute scripts with 777 or any other writable permissions for security reasons.
Try to set 644 permissions for that file.
关于您的后续问题:另一台服务器是什么类型的服务器?另外,问题是特定脚本还是所有脚本?你可以在你的 cgi-bin 中使用任何脚本吗?如果没有,可能你的虚拟主机配置不正确,或者 perl 可能安装在其他地方。
Regarding your follow-on question: what kind of server is the other server? Also, is the problem a specific script or all scripts? Can you use any scripts in your cgi-bin? If not, perhaps your virtual host is not configured properly, or perhaps perl is installed somewhere else.
我已经与托管公司交谈过,他们说他们不提供任何“CGI/PERL”脚本托管...
所以,问题解决了...(有点)。
教训:在购买托管套餐之前一定要仔细阅读:D
I've talked to the hosting firm and they said that they don't offer any "CGI/PERL" sript hosting...
So , problem solved... (kind of).
LESSON: Always read carefully before buying a hosting package :D