【问题标题】:C++ CGI - Internal Server Error - when is used stringC++ CGI - 内部服务器错误 - 何时使用字符串
【发布时间】:2020-07-17 13:34:27
【问题描述】:

这段代码:

#include <iostream>
using namespace std;
int main()
{
        cout << "content-type: text/html" << endl << endl;
        cout << "<h1>CGI C++ example</h1>" << endl;
        return 0;
}

编译后(在Ubuntu,Apache2中)并上传到我的网站主机,在/cgi-bin/文件夹中,它工作正常 如果我在编译后添加字符串(在 Ubuntu、Apache2 中)并在我的网站主机中上传,结果是“内部服务器错误”

#include <iostream>
#include <string>
using namespace std;
int main()
{
        cout << "content-type: text/html" << endl << endl;
        string alabala;
        cout << "<h1>CGI C++ example</h1>" << endl;
        return 0;
}

提前感谢 cmets

【问题讨论】:

  • 第二个程序是完全合法的。无论您的错误的原因是什么,它都与您发布的代码无关。可能问题出在您使用主机的方式上。
  • 您应该在您的网络服务器的日志中找到更多信息。
  • 在以前版本的代码中,我包含了 'string alabala = "Somethig";'和'cout
  • @RaUndreundre 假设你做的一切都是正确的,那么我能想到的唯一可能的原因是 C++ 运行时库中的某种版本控制问题。真的帮不了你,代码很好。
  • @RaUndreundre 你能打开你的主机的控制台窗口吗?这将是找出问题所在的方法。

标签: c++ cgi


【解决方案1】:

我发现一些虚拟主机公司阻止了非 perl cgi 脚本!然后我尝试了 foo.pl 就可以了!但是如果我从 pascal 或 c++ 编译它会失败!到目前为止,对我来说唯一的解决方案是使用带有个性化 apache conf 的 VPS 来实现我的目的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-09
    • 2013-11-13
    • 2016-04-24
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多