Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
    /etc/apache2/mods-enabled
    # 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
    </IfModule>
    
  • 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: http://127.0.0.1/fcgitest/run.fcgi
  • 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 serverfault.com/questions/175515/… –  joschi Aug 28 '10 at 6:47

1 Answer 1

up vote 1 down vote accepted

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

http://127.0.0.1/doc/libapache2-mod-fastcgi/mod_fastcgi.html
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html

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

 
discard

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.