Chumby as a web server

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

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

Put together a Linux system

Interanll, we use Ubuntu Dapper Drake, however, pretty much any contemporary Linux system will work. Be sure you have the normal GNU toolcahin 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 for how to install the GNU Toolchain

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

Withing the lightydirectory, 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"
)

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
# hide overlay buffer
echo 0 > /proc/driver/imxfb/alpha
# display the ip of the device on the screen
fbwrite "`ifconfig rausb0 | grep inet`"
# start lighttpd
/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.