This is an old revision of the document!


HOWTO Build lighttpd

First, set up your crosscompile toolchain. Download build_lighttpd_pa1.tgz. Extract, edit the file to correct the bug in tar xvfz zips/.tar.gz –> tar xvfz zips/$APP-$APP_VER.tar.gz and then execute.

Transfer the result, dns323_lighttpd-1.4.13.tar.gz, to /mnt/HD_a2 and extract it lnx_bin/busybox3 tar xvz -f dns323_lighttpd-1.4.13.tar.gz

Create a file, index.html, located in /mnt/HD_a2/www:

<html>
  <body>
    Hello World from DNS-323
  </body>
</html>

Create a file, lighttpd.conf, located in /mnt/HD_a2/lnx_bin:

server.document-root = "/mnt/HD_a2/www/"
server.port = 3000
mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)

Now, let lighttpd analyze the file using ./lighttpd -t -f lighttpd.conf and if that worked out, start the server using ./lighttpd -D -f lighttpd.conf

Access your server on port 3000, e.g. http://192.168.0.200:3000/index.html

Notes on the application

The default path for the mod_-files are compiled into the application to be /mnt/HD_a2/lnx_bin/lib using the -DLIBRARY_DIR directive. To have the modules in another directory, change the build script or start the server with argumet -m PATH

Note on lighttpd version

Beginning with 1.5.0, lighttpd depends on glib2.

Notes on using port 80 for lighttpd

For fun-plug v0.5 click here and look for Port 80 for fun-plug versions 0.3 & 0.4 see below…

Since the DNS-323 Admin service (webs) uses port 80 in order to use port 80 for lighttpd you'll need to do the following:

  1. Modify ligttpd.conf file to include “server.port = 80”
  2. Stop the lighttpd service
  3. Stop the 'webs' service
  4. Start the lighttpd service

or use the two scripts below and make sure you put them in ./fun_plug.d/start directory with the correct CHMOD settings so they run automatically.

The admin service on your DNS-323 will now be available on port 81. To access: http://192.168.0.200:81

Here's the 'lighttpd.sh' script:

#!/bin/sh
#
# This script was modified by Paul Imhof on 2/2/08 as a work around
# in getting the admin website off of port 80 and on to port 81
# It is used in conjuction with admwebs.sh (created) which is
# called from this script. lighttpd.sh stops (via admwebs.sh) the
# web admin service and then starts lighttpd on port 80. The web admin
# now (automatically) starts on port 81 after a few seconds. The admin
# service tests for use on port 80. If it's in use then bumps to the 
# next available port (in this case it's bumped to port 81).
#
# NOTE:
# ./fun_plug.d/etc/lighttpd.conf needs to be configured to use
# port 80
#
# USE "netstat -tln" to verify that both port 80 & 81 are in use.
#

lighttpd_start() {

    # make sure, upload directory exists
    # path must match server.upload-dirs in lighttpd.conf file!
    mkdir -p ${VOL1}/tmp
    chmod 01777 ${VOL1}/tmp

    if [ -x "${SBINDIR}/lighttpd" ]; then
        echo "Stopping WEB admin"
        /mnt/HD_a2/fun_plug.d/start/admwebs.sh stop
        echo "Starting lighttpd... "
        ${SBINDIR}/lighttpd -f ${ETCDIR}/lighttpd.conf 1>/dev/null 2>/dev/null </dev/null
        echo "Starting WEB admin on port 81"
        /mnt/HD_a2/fun_plug.d/start/admwebs.sh start
        echo "done!" 
    else
        echo "ERROR: lighttpd not found or not executable"
    fi
}

lighttpd_stop() {
    killall lighttpd
}


lighttpd_status() {
    if [ -n "$(pidof lighttpd)" ]; then
        echo "running"
    else
        echo "stopped"
    fi
}

case "$1" in
    stop)
        lighttpd_stop
        ;;
    restart)
        lighttpd_stop
        sleep 1
        lighttpd_start
        ;;
    status)
        lighttpd_status
        ;;
    start|'')
        lighttpd_start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|status"
        ;;
esac

Here's the 'admwebs.sh' script:

#!/bin/sh
#
# This script was created by Paul Imhof on 2/2/08 as a work around
# in getting the admin website off of port 80 and on to port 81
# It is used in conjuction with lighttpd.sh (also modified) which
# calls this script. When used from lighttpd.sh it stops the
# web admin service then starts lighttpd on port 80. The web admin
# service notices that something is on port 80 and then starts on
# port 81.
#
# NOTE:
# ./fun_plug.d/etc/lighttpd.conf needs to be configured to use
# port 80
#
# NOTE2: (2/14/08)
#  Updated this script to remove "Starting" webs. Apparently
#  if you start webs you will not be able to add users
#  webs is set to automatically restart if the /web/webs service
#  is stopped.
#

admwebs_start() {
    if [ -x "/web/webs" ]; then
#       echo "Starting webs... "
#       /web/webs & > /dev/null
        echo "/webs/webs service will start automatically in 45 sec"
    else
        echo "ERROR: /web/webs not found or not executable"
    fi
}

admwebs_stop() {
    killall webs
}

admwebs_status() {
    if [ -n "$(pidof webs)" ]; then
        echo "running"
    else
        echo "stopped"
    fi
}

case "$1" in
    stop)
        admwebs_stop
        ;;
    restart)
        admwebs_stop
        sleep 1
        admwebs_start
        ;;
    status)
        admwebs_status
        ;;
    start|'')
        admwebs_start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|status"
        ;;
esac

Easy Ways

  • A pre-compiled variant can be found here
  • lighttpd is also included in fonz's fun_plug pack, a comprehensive fun_plug package that's easy to implement and great for first time users. php is a separate package that can be added easily. Instructions are provided.

Navigation

Personal Tools