This article illustrates how to config lighttpd web server to run cgi written in C

Hello world example

Save this "Hello world !" source code example in /var/www/cgi-bin (create this directory if it not exists).

#include "stdio.h"
 
int main(void) {
  printf( "Content-Type: text/plain\n\n" );
  printf("Hello world !\n");
  return 0;
}

Compile it typing:

debarm:~# gcc hello.c -o hello.cgi

lighttpd configuration

Change the server.modules list inside /etc/lighttpd/lighttpd.conf in:

server.modules              = (
            "mod_access",
            "mod_cgi",
            "mod_alias",
            "mod_accesslog",
            "mod_compress",
)

and add these lines:

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

cgi.assign      = (
        ".cgi"  => ""
)

Restart lighttpd typing:

debarm:~# /etc/init.d/lighttpd restart

Final test

Access with your browser to the FOX Board web page using this URL:

http:///cgi-bin/hello.cgi

Documentation Terms of Use
The Acme Systems srl provides this Debian system development and user manual.
The origin of these doc came from the website: http://www.acmesystems.it
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Creative Commons License

关注我们: 微博

销售邮箱:market@armdevs.com
技术支持: support@armdevs.com
销售电话: +86-755-29638421


核风在线支持>
在线时间:09:00-18:00
Copyright @ 2014 to 2020 - 核风智能技术有限公司