Configuring lighttpd to handle CGI C executables
Asked Answered
D

1

6

Does anyone know how to configure lighttpd to handle plain CGI executables, in this case written in C? I have compiled a test program (test.cgi) and put it in $HOME/public_html/cgi-bin. I have also enabled the CGI module with lighty-enable-mod cgi and restarted the web server. Still, when requesting http://localhost/~august/cgi-bin/test.cgi the program is not run but is instead treated as a static file. Here is my test program by the way:

#include <stdio.h>

int main(void)
{
   printf("Content-type: text/plain\n\n");
   puts("test...");
   return 0;
}
Degrease answered 7/6, 2011 at 14:49 Comment(0)
D
10

The default CGI configuration looks like this:

$HTTP["url"] =~ "^/cgi-bin/" {
    cgi.assign = ( "" => "" )
}

i.e. only binaries in the cgi-bin directory under the document root will be executed. To enable per-user cgi directories, add

$HTTP["url"] =~ "^(/~[^/]+)?/cgi-bin/" {
    cgi.assign = ("" => "")
}

to the lighttpd configuration file.

Degrease answered 8/6, 2011 at 15:51 Comment(3)
I have added the second set of lines to my lighttpd config but it still serves the cgi file as if it were static (ie tries to download it)Empale
just to clarify, my cgi file is in the /var/www/ folderEmpale
This might do the trick: chcon -R -t httpd_sys_script_exec_t cgi-binIngaborg

© 2022 - 2024 — McMap. All rights reserved.