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 xvzf zips/$APP-$APP_VER.tar.gz and then execute.

Quick helper: Also note that you need to create a /zips/ folder (or add it to the above script right after [if ! -f zips ]), otherwise the script breaks

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

Lighttpd for Windows Users

if you don't speak linux gibberish:

Before you begin:

Install Putty on your PC: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Install Netscan on your PC: http://www.softperfect.com/products/networkscanner/

Run Netscan. click the Options tab, then the Additional subtab. Click all the buttons. in the box on the bottom type 22, 23, 80, 443, 8080. Click OK.

Click the IP box, then click the range of your network in the box that pops up.

these files must be in these locations in Volume_1 of the DNS-323:

lighttpd.sh in /ffp/start

lighttpd.conf in ffp/etc/examples

these files are installed by default when fun plug runs the first time

Create these folders:

Volume_1/www

Volume_1/www/logs

Volume_1/www/pages

Run Putty. You will get a black box with an octet: # and a green cursor. you will enter the commands below at the green cursor. the octet is shown as a

reference point.

this command will copy the lighttpd configuration file /examples to ffp/etc:

# cd /ffp/etc

# cp examples/lighttpd.conf /ffp/etc/lighttpd.conf

this makes the lighttpd shell file in the /ffp/start directory executeable:

# cd /ffp/start

# chmod +x lighttpd.sh

it will not start if lighttpd.conf is not in /ffp/etc

to manually start lighttpd:

# sh /ffp/start/lighttpd.sh start

If it's running you will see port 8080 open on your DNS-323 when you Start Scanning in Netscan


Navigation

Personal Tools