Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's been a few days that I'm trying to set up fastcgi with apache on a Kubuntu server. Despite searching everywhere, I cannot make it to work. If I try to run the site with the cgi application, apache hangs and after the timeout returns a 500 error.

Here is what I did:

  • I made sure that mod_fastcgi is installed and enabled:

    # pwd
    # ls -l f*
    lrwxrwxrwx 1 root root 30 2010-07-22 10:01 fastcgi.conf -> ../mods-available/fastcgi.conf
    lrwxrwxrwx 1 root root 30 2010-07-22 10:01 fastcgi.load -> ../mods-available/fastcgi.load
  • As far as I am aware, fastcgi.conf is properly configured:

    <IfModule mod_fastcgi.c>
      AddHandler fastcgi-script .fcgi
      #FastCgiWrapper /usr/lib/apache2/suexec
       FastCgiIpcDir /var/lib/apache2/fastcgi
  • I am using this very simple sample script to test the set up:

    #include <iostream>
    using namespace std;
    int main()
            cout<<"Content-type: text/plain"<<endl<<endl;
            cout<<"Hello World!"<<endl;
             return 0;
  • I compiled it. It works fine from the command line.
  • I placed it within a folder visible from the web server:
  • At first I get: "Forbidden. You don't have permission to access /fcgitest/run.fcgi on this server.".
  • I add a .htaccess file in the folder:

    Options +ExecCGI -Indexes
  • And now, when I try to access the script address from my web browser, I get the symptom I described at the beggining: the browser first hangs, and after the timeout, I get a 500 Internal Server Error.
  • The apache error.log say:

    Content-type: text/plain
    Hello World!
    [Sat Aug 28 09:08:23 2010] [warn] FastCGI: (dynamic) server 
    "/var/www/fcgitest/run.fcgi" (pid 27758) terminated by calling exit with status '0'

It seems the output is written to the error logs!! Is there a missing socket configuration, somewhere??

share|improve this question
Exact duplicate of… – joschi Aug 28 '10 at 6:47
up vote 2 down vote accepted

As noted by joschi, CGI != FastCGI . A CGI script would fail in this context.

FastCGI Specification Compliance

The FastCGI specification is not implemented in its entirety and I've deviated a bit as well resulting in some Apache specific features.

The file descriptors for stdout and stderr are left open. This is prohibited by the specification. I can't see any reason to require that they be closed, and leaving them open prevents FastCGI applications which were not completely ported to FastCGI from failing miserably. This does not mean the applications shouldn't be fixed such that this doesn't occur, but is invaluable when using a 3rd party library (without source code) which expects to be able to write to stderr. Anything written to stdout or stderr in this manner will be directed to the main server log.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.