Avatar of dmontgom
dmontgom

asked on 

Trying to get c++ cgi script to work in Ubuntu Apache2

Hi,
I am new to Ubuntu.  My python cgi-scripts work but my c++ cgi does not.  How do I fix?
\
  In the apache error logs I get premature end of headers error.  
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log



Below is my simple cgi script.  I also did a chmod a+x and 755.  In the http.conf file I have

ScriptAlias /cgi-bin /usr/lib/cgi-bin/
<Directory /usr/lib/cgi-bin>
    Options +ExecCGI
    Order allow,deny
    Allow from all
    AddHandler cgi-script cgi o py
</Directory>


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <string>
#include <time.h>
#include <malloc.h>

using namespace std;


int main() {

      cout << "content-type: text/html" << endl << endl;
      cout << "<html>" << endl;
      cout << "</html>" << endl;


      //cout   << "Hello! You sent " << lpszContentLength << " bytes of data which read: <br>" << endl;

      return 0;
}
Scripting LanguagesC++Apache Web ServerWeb ApplicationsLinux

Avatar of undefined
Last Comment
dmontgom
Avatar of DalHorinek
DalHorinek
Flag of Czechia image

What is in error log?
Avatar of dmontgom
dmontgom

ASKER

Here the error log

[Sun Sep 12 18:33:09 2010] [error] (8)Exec format error: exec of '/usr/lib/cgi-bin/cpp_post_test.o' failed
[Sun Sep 12 18:33:09 2010] [error] [client 127.0.0.1] Premature end of script headers: cpp_post_test.o
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of dmontgom
dmontgom

ASKER

Good job!

Thanks
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo