0

I am trying to get Apache2.4 to run compiled fastcgi programs on an Ubuntu 14.04-based system. I am using mod_fastcgi and am getting the errors

FastCGI: can't start server "/var/www/fcgi/fhello.fcgi" (pid 29037), execle() failed: Permission denied
[Sun Jun 14 14:16:23.322632 2015] [:warn] [pid 29022] FastCGI: server "/var/www/fcgi/fhello.fcgi" (pid 29037) terminated by calling exit with status '255'

my apache config block looks like

<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
  FastCgiWrapper /var/lib/apache2/fastcgi
  FastCgiServer /var/www/fcgi/fhello.fcgi -socket /var/www/fcgi/fhello.sock -user www-data -group www-data
  ScriptAlias /fhello "/var/www/fcgi/fhello.fcgi"
  <Directory /var/www/fgci>
    Require all granted
    Options ExecCGI
  </Directory>
</IfModule>

if it helps the fhello code is

#include "fcgi_stdio.h" /* fcgi library; put it first*/
#include <stdlib.h>

int count;

void initialize(void) {
  count=0;
}

int main(void) {
/* Initialization. */  
  initialize();

/* Response loop. */
  while (FCGI_Accept() >= 0) {
    printf("Content-type: text/html\r\n"
      "\r\n"
      "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
      "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
      "Request number %d running on host <i>%s</i>\n",
      ++count, getenv("SERVER_HOSTNAME"));
  }
  return 0;
}

www-data owns and has exec rights to the program, and has write permissions to the fcgi dir for the sock file. This is my first time setting up anything to run as fastcgi besides perl forever ago and I seem to be lacking in the google-fu to find effective information on this subject.

If anyone can point out what I am doing wrong or what I have missed, please do so.

1 Answer 1

1

So after some face palming the code snippet I was using seg faulted at getenv("SERVER_HOSTNAME") see

  "Request number %d running on host <i>%s</i>\n",
  ++count, getenv("SERVER_HOSTNAME"));

so I replaced that with (also fixed the html)

   "Request number %d running on host <i>host</i></body></html>\n",
    ++count);

and in the apache config I simplified it to

<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
  FastCgiServer /var/www/fcgi/fhello.fcgi
  ScriptAlias /fhello.fcgi "/var/www/fcgi/fhello.fcgi"
</IfModule>

letting the server manage the connection. I still haven't figured out the permissions issue I was getting above, but everything is working as I want it now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .