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??
Your sample script is wrong. It needs to explicitly support FastCGI e. g. through
fastcgi++
or the official FastCGI SDK.But that's more of a question for StackOverflow.
Yep, 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