Home > 1, ARM, orange pi, Software > Set up lighttpd server with fastcgi support on Orange Pi

Set up lighttpd server with fastcgi support on Orange Pi

  1. Install lighttpd and fastcgi: sudo apt-get install lighttpd libfcgi-dev libfcgi0ldbl
  2. Now you have lighttd installed and running. You can test it by opening http://orange_ip_address
  3. In the home directory create folder cgi_test: mkdir ~/cgi_test && cd ~/cgi_test
  4. It’s time to create your first CGI prnt.c” with the  following code:
    #include <fcgi_stdio.h>
    #include <stdlib.h>
    
    int main(void) {
        while (FCGI_Accept() >= 0) {
            printf("Content-type: text/plain\r\n\r\n"
                   "Hello from fastcgi!\n");
        }
        return 0;
    }
    
  5. Build it! gcc prnt.c -lfcgi -o prnt.fcgi
  6. Add to the fastcgi config file /etc/lighttpd/conf-enabled/10-fastcgi.confthis text:
    # /usr/share/doc/lighttpd/fastcgi.txt.gz
    # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi
    
    server.modules += ( "mod_fastcgi" )
    
    fastcgi.debug = 1
    fastcgi.server = (
        "/prnt" => (
        "echo.fcgi.handler" => (
            "socket" => "/tmp/echo.fcgi.socket",
            "check-local" => "disable",
            "bin-path" => "/home/argrento/cgi_test/prnt.fcgi",
            "max-procs" => 1
        ))
    )
    
  7. Do not forget to change bin-path to you valid path from the p. 3
  8. Restart lighttpd: sudo service lighttpd reload and enjoy!

    hello

    Tests are OK!

Further readings:
http://yaikhom.com/2014/12/18/handling-requests-c-fast-cgi-and-lighttpd.html
http://yaikhom.com/2014/09/13/lean-web-services-using-c-fast-cgi-and-mysql.html

Advertisements
Categories: 1, ARM, orange pi, Software
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: