Coder Social home page Coder Social logo

jefftsengtwn / lighttpd-fastcgi-c Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jerryvig/lighttpd-fastcgi-c

0.0 0.0 0.0 6 KB

Minimal example of using FastCGI C programs compiled with gcc with the lighttpd ("lighty") web server.

C 80.04% HTML 19.96%

lighttpd-fastcgi-c's Introduction

This is a minimal example for how to build FastCGI apps written in C with gcc, and run those C apps with the lighttpd ("lighty") general purpose web server.

This example was built with lighttpd-1.4.x (https://github.com/lighttpd/lighttpd1.4). To run this example you will need to ensure that lightttpd's mod_fastcgi is enabled. It is enabled by default with the standard lighttpd distribution. You'll also need the FastCGI developer kit fcgi2 (https://github.com/FastCGI-Archives/fcgi2) installed on your system.

To build and install FastCGI developer kit do the following from the command line:

$ git clone https://github.com/FastCGI-Archives/fcgi2
$ cd fcgi2/
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

After installing the FastCGI developer kit (fcgi2), you should then be able to build the C application with:

$ gcc hello_fastcgi.c -o hello_fastcgi.fcgi -lfcgi -O3 -Wall -Wextra -pedantic -std=c11

The key configuration of the FastCGI server is at the end of this lightttpd.conf file. The line "bin-path" => "hello_fastcgi.fcgi" tells lighttpd to launch a persistent background FastCGI process for the hello_fastcgi.fcgi application. The line "socket" => "/tmp/hello_fastcgi.sock" tells lighttpd to communicate with the background proc(s) via unix socket(s). lighttpd can also communicate with FastCGI apps via TCP. See the lighttpd modfastcgi documentation at https://redmine.lighttpd.net/projects/lighttpd/wiki/docs_modfastcgi for more examples and further explanation.

fastcgi.debug = 1
fastcgi.server = (
  "/hello" => ((
    "bin-path" => "hello_fastcgi.fcgi",
    "socket" => "/tmp/hello_fastcgi.sock",
    "check-local" => "disable",
    "max-procs" => 2,
  ))
)

After building the FastGCI C application with gcc, you should now be able to run hello_fastcgi.fcgi with lighttpd as the http web front end. You can then navigate to http://localhost:8080/hello to see the output of your FastCGI application.

$ lighttpd -D -f lighttpd.conf

lighttpd-fastcgi-c's People

Contributors

jerryvig avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.