Chumby as a web server

From Chumby Wiki
Revision as of 10:54, 12 August 2007 by Chumby (Talk | contribs)

Jump to: navigation, search

Here's how to build lighttpd for your chumby. You'll be creating and installing lighttpd to run from a USB dongle.

Put together a Linux development system

Internally, we tend to use Kubuntu Dapper Drake, however, pretty much any contemporary Linux system will work. Be sure you have the normal GNU toolchain installed - on Ubuntu and other Debian-based systems, sudo apt-get install build-essential should do the trick.

Under MacOS or Windows, you should be able to run something like VMWare to run a Linux system.

Install the ARM toolchain

Follow the directions to install the GNU Toolchain for the ARM9 processor used in the chumby.

Download and unpack the source code for lighttpd

# wget http://www.lighttpd.net/download/lighttpd-1.4.16.tar.gz
# tar xzvf lighttpd-1.4.16.tar.gz

Build it

# cd lighttpd-1.4.16
# ./configure --build=i386-linux --host=arm-linux --prefix=/mnt/usb/lighty
# make

Under Ubuntu, I typically create a directory at /mnt/usb which will then be copied to a USB dongle, since Ubuntu normally mounts such devices at /media. However, for your distro, you might want to simply mount a dongle at that mount point.

Install it

# make install

At this point, you should have a directory /mnt/usb/lighty which has bin, lib and sbin directories.

Copy this directory to a USB dongle - the dongle should have the lighty directory at the top.

Create the document directories

Within the lighty directory, create the directories html and cgi-bin.

At this point, you might also want to create a simple index.html file and put it in the html directory.

Create a simple lighttpd.conf file

So now we need a simple conf file to tell lighttpd what it's supposed to do. Create the file lighttpd.conf file and put it in the lighty directory, with the contents:

server.modules = ( "mod_cgi", "mod_accesslog" )
server.document-root = "/mnt/usb/lighty/html"
server.errorlog = "/tmp/logs/lighttpd.error.log"
accesslog.filename = "/tmp/logs/lighttpd.access.log"
index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )
cgi.assign = ( "/mnt/usb/lighty/cgi-bin")
mimetype.assign             = (
 ".pdf"          =>      "application/pdf",
 ".sig"          =>      "application/pgp-signature",
 ".spl"          =>      "application/futuresplash",
 ".class"        =>      "application/octet-stream",
 ".ps"           =>      "application/postscript",
 ".torrent"      =>      "application/x-bittorrent",
 ".dvi"          =>      "application/x-dvi",
 ".gz"           =>      "application/x-gzip",
 ".pac"          =>      "application/x-ns-proxy-autoconfig",
 ".swf"          =>      "application/x-shockwave-flash",
 ".tar.gz"       =>      "application/x-tgz",
 ".tgz"          =>      "application/x-tgz",
 ".tar"          =>      "application/x-tar",
 ".zip"          =>      "application/zip",
 ".mp3"          =>      "audio/mpeg",
 ".m3u"          =>      "audio/x-mpegurl",
 ".wma"          =>      "audio/x-ms-wma",
 ".wax"          =>      "audio/x-ms-wax",
 ".ogg"          =>      "application/ogg",
 ".wav"          =>      "audio/x-wav",
 ".gif"          =>      "image/gif",
 ".jpg"          =>      "image/jpeg",
 ".jpeg"         =>      "image/jpeg",
 ".png"          =>      "image/png",
 ".xbm"          =>      "image/x-xbitmap",
 ".xpm"          =>      "image/x-xpixmap",
 ".xwd"          =>      "image/x-xwindowdump",
 ".css"          =>      "text/css",
 ".html"         =>      "text/html",
 ".htm"          =>      "text/html",
 ".js"           =>      "text/javascript",
 ".asc"          =>      "text/plain",
 ".c"            =>      "text/plain",
 ".cpp"          =>      "text/plain",
 ".log"          =>      "text/plain",
 ".conf"         =>      "text/plain",
 ".text"         =>      "text/plain",
 ".txt"          =>      "text/plain",
 ".dtd"          =>      "text/xml",
 ".xml"          =>      "text/xml",
 ".mpeg"         =>      "video/mpeg",
 ".mpg"          =>      "video/mpeg",
 ".mov"          =>      "video/quicktime",
 ".qt"           =>      "video/quicktime",
 ".avi"          =>      "video/x-msvideo",
 ".asf"          =>      "video/x-ms-asf",
 ".asx"          =>      "video/x-ms-asf",
 ".wmv"          =>      "video/x-ms-wmv",
 ".bz2"          =>      "application/x-bzip",
 ".tbz"          =>      "application/x-bzip-compressed-tar",
 ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
)

Note that this is a pretty minimal configuration file - we actually ended up building most of the lighttpd modules (they're in the lib directory), so you may wish to review the online documentation to enable other capabilities.

Create the "debugchumby" file to launch the server on boot

At the top level of the USB dongle, create a file called debugchumby with the contents:

#!/bin/sh
# kill the built-in web server
killall httpd
# create the log directory
mkdir /tmp/logs
# start lighttpd
LD_LIBRARY_PATH=/mnt/usb/lighty/lib /mnt/usb/lighty/sbin/lighttpd -f /mnt/usb/lighty/lighttpd.conf

Reboot your chumby with the USB dongle installed

You should now have a web server responding on the IP of the chumby. You can get the IP by looking on the Settings->Chumby Info screen in the Control Panel

Don't want to build it yourself?

No worries - we've already built this for you:

  • Download chumby_lighttpd.tar.gz to a USB dongle
  • Unpack it
  • Put the dongle into the back of your chumby and reboot!