Chumby as a web server

From Chumby Wiki
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
# 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.

  • Note: under some environments, lighthttpd will fail to build with the following error:
configfile.c: In function 'config_parse_cmd':
configfile.c:919: error: 'PATH_MAX' undeclared (first use in this function)
configfile.c:919: error: (Each undeclared identifier is reported only once
configfile.c:919: error: for each function it appears in.)
configfile.c:919: warning: unused variable 'oldpwd'
make[2]: *** [configfile.o] Error 1
make[2]: Leaving directory `/home/user/lighttpd-1.4.16/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/user/lighttpd-1.4.16'
make: *** [all] Error 2

To fix this problem, edit the file lighttpd-1.4.16/src/configfile.c and add #include <linux/limits.h> to the beginning of the file. This problem was identified on Ubuntu Gutsy Server x86_64

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.

You'll put your HTML files in the html directory, and your scripts in the cgi-bin directory.

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", "mod_alias" )                                
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 = ( ".sh" => "/bin/sh", ".pl" => "/usr/bin/perl" )                         
alias.url = ( "/cgi-bin/" => "/mnt/usb/lighty/cgi-bin/", "/images/" => "/mnt/usb/images/" )
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:

# 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.

Since the system is creating log files to /tmp, which is a RAM partition on the chumby, you'll eventually fill up the memory. At some point, you may wish to redirect the logs to the USB dongle, or to /dev/null if you don't want them at all - this is done by editing the lighttpd.conf file.

Don't want to build it yourself?

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