【发布时间】: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 你能打开你的主机的控制台窗口吗?这将是找出问题所在的方法。