访问cgi文件时收到错误代码500(在c ++中)

时间:2016-04-25 19:50:12

标签: cgi

我在godaddy web host上的一个名为test.cpp的文件中编写了以下代码:

#include <iostream>
using namespace std;
int main () {
   cout << "Content-type:text/html\r\n\r\n";
   cout << "<html>\n";
   cout << "<head>\n";
   cout << "<title>Hello World - First CGI Program</title>\n";
   cout << "</head>\n";
   cout << "<body>\n";
   cout << "<h2>Hello World! This is my first CGI program</h2>\n";
   cout << "</body>\n";
   cout << "</html>\n";

   return 0;
}

我使用“g ++ test.cpp -o a.cgi”在godaddy主机上编译test.cpp。 然后我尝试访问cgi(类型“www.XXX.com/a.cgi”),错误代码500出来了。我不知道出了什么问题。

1 个答案:

答案 0 :(得分:0)

  1. 使用文件管理器更改文件的权限以使其可执行
  2. 尝试www.xxx.com/cgi-bin/a.cgi
  3. a.cgi更改为a.cpp,然后检查是否有效