Lighttpd

Lighttpd unter Debian Testing (Etch)

Benötigte Pakete

  • pkg-config
  • openssl
  • libssl-dev
  • autoconf
  • automake
  • libbz2-dev
  • libpcre3-dev
  • libpcre3
  • libfcgi-dev
  • libfcgi0
  • libxml2-dev
  • xml-core
  • sqlite3
  • libsqlite3-dev

Achtung: Es wird natürlich nicht alles benötigt. Dies ist lediglich eine Auswahl und obliegt den gewünschten Features von lighttpd.

Nützlich

Kompilieren

Eigentlich der klassische Dreisatz:

./configure
make
make install

Aber:

andrer@bebo:~/downloads/lighttpd-1.4.12$ ./configure --bindir=/usr/bin \
--sbindir=/usr/sbin --datadir=/usr/share --sysconfdir=/etc \
--localstatedir=/var --libdir=/usr/lib --disable-ipv6 --without-ldap \
--without-kerberos5 -without-fam --without-lua --without-gdbm \
--without-memcache --with-openssl-includes=/usr/include/openssl \
--with-openssl-libs=/usr/lib --with-pcre --with-bzip2 \
--with-webdav-props

Das ergibt folgendes Ergebnis:

Plugins:
 
enabled: 
  mod_access
  mod_accesslog
  mod_alias
  mod_auth
  mod_cgi
  mod_compress
  mod_dirlisting
  mod_evhost
  mod_expire
  mod_fastcgi
  mod_flv_streaming
  mod_indexfiles
  mod_proxy
  mod_redirect
  mod_rewrite
  mod_rrdtool
  mod_scgi
  mod_secdownload
  mod_setenv
  mod_simple_vhost
  mod_ssi
  mod_staticfile
  mod_status
  mod_trigger_b4_dl
  mod_userdir
  mod_usertrack
  mod_webdav
disabled: 
  mod_cml
  mod_magnet
  mod_mysql_vhost
 
Features:
 
enabled: 
  auth-crypt
  compress-bzip2
  compress-deflate
  compress-gzip
  large-files
  network-openssl
  regex-conditionals
  webdav-properties
disabled: 
  auth-ldap
  network-ipv6
  stat-cache-fam
  storage-gdbm
  storage-memcache
andrer@bebo:~/downloads/lighttpd-1.4.12$ make
andrer@bebo:~/downloads/lighttpd-1.4.12$ su -
Password: 
bebo:~# cd /home/andrer/downloads/lighttpd-1.4.12
bebo:/home/andrer/downloads/lighttpd-1.4.12# checkinstall 
 
checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.
 
The checkinstallrc file was not found at:
/usr/local/lib/checkinstall/checkinstallrc
 
Assuming default values.
 
The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: y
 
Preparing package documentation...OK
 
Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? D
 
 
Please write a description for the package.
End your description with an empty line or EOF.
>> Lighttpd
>>    
 
*****************************************
**** Debian package creation selected ***
*****************************************
 
This package will be built according to these values: 
 
0 -  Maintainer: [ root@bebo ]
1 -  Summary: [ Lighttpd ]
2 -  Name:    [ lighttpd ]
3 -  Version: [ 1.4.12 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ lighttpd-1.4.12 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
 
Enter a number to change any of them or press ENTER to continue: 5
Enter the license type: 
>> BSD
 
This package will be built according to these values: 
 
0 -  Maintainer: [ root@bebo ]
1 -  Summary: [ Lighttpd ]
2 -  Name:    [ lighttpd ]
3 -  Version: [ 1.4.12 ]
4 -  Release: [ 1 ]
5 -  License: [ BSD ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ lighttpd-1.4.12 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
 
Enter a number to change any of them or press ENTER to continue: 0
Enter the maintaner's name and e-mail address: 
>> andre.raabe@gmx.de
 
This package will be built according to these values: 
 
0 -  Maintainer: [ andre.raabe@gmx.de ]
1 -  Summary: [ Lighttpd ]
2 -  Name:    [ lighttpd ]
3 -  Version: [ 1.4.12 ]
4 -  Release: [ 1 ]
5 -  License: [ BSD ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ lighttpd-1.4.12 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
 
Enter a number to change any of them or press ENTER to continue: 9
Enter the alternate source location: 
>> http://www.lighttpd.net/
 
This package will be built according to these values: 
 
0 -  Maintainer: [ andre.raabe@gmx.de ]
1 -  Summary: [ Lighttpd ]
2 -  Name:    [ lighttpd ]
3 -  Version: [ 1.4.12 ]
4 -  Release: [ 1 ]
5 -  License: [ BSD ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ lighttpd-1.4.12 ]
9 -  Alternate source location: [ http://www.lighttpd.net/ ]
10 - Requires: [  ]
 
Enter a number to change any of them or press ENTER to continue:
 
.
.
.
 
 
 
**********************************************************************
 
 Done. The new package has been saved to
 
 /home/andrer/downloads/lighttpd-1.4.12/lighttpd_1.4.12-1_i386.deb
 You can install it in your system anytime using: 
 
      dpkg -i lighttpd_1.4.12-1_i386.deb
 
**********************************************************************

Installieren

dpkg -i lighttpd_1.4.12-1_i386.deb

Konfigurieren

  • mkdir -p /srv/www/htdocs
  • cp /usr/doc/lighttpd-1.4.12/doc/lighttpd.conf /etc/
  • vim /etc/lighttpd.conf
  • Konfiguration checken:
bebo:/etc# lighttpd -f /etc/lighttpd.conf -t
Syntax OK
  • Testlauf:
bebo:/etc# lighttpd -f /etc/lighttpd.conf -D
bebo:~/downloads# tail -f /var/log/lighttpd_error.log 
2006-10-04 22:48:49: (log.c.75) server started

Startscript fuer Debian Testing (Etch) erstellen

bebo:/etc# cp /etc/init.d/skeleton /etc/init.d/lighttpd
bebo:/etc# chmod 755 /etc/init.d/lighttpd
bebo:/etc# vim /etc/init.d/lighttpd

Komplettes Startscript:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          lighttpd
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Initscript for lighttpd
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO
 
# Author: Andre Raabe <andre.raabe@gmx.de>
#
 
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="Lighttpd Webserver"
NAME=lighttpd
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="-f /etc/lighttpd.conf"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
 
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
 
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS
 
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
 
#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
}
 
#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
        # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return "$RETVAL"
}
 
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
        #
        # If the daemon can reload its configuration without
        # restarting (for example, when it is sent a SIGHUP),
        # then implement that here.
        #
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
        return 0
}
 
case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  #reload|force-reload)
        #
        # If do_reload() is not implemented then leave this commented out
        # and leave 'force-reload' as an alias for 'restart'.
        #
        #log_daemon_msg "Reloading $DESC" "$NAME"
        #do_reload
        #log_end_msg $?
        #;;
  restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

RRDTool aktivieren

  • mkdir /srv/www/htdocs/rrd
  • vim /etc/lighttpd.conf
server.modules              = (
#                               "mod_rewrite",
#                               "mod_redirect",
#                               "mod_alias",
                                "mod_access",
#                               "mod_cml",
#                               "mod_trigger_b4_dl",
#                               "mod_auth",
#                               "mod_status",
#                               "mod_setenv",
#                               "mod_fastcgi",
#                               "mod_proxy",
#                               "mod_simple_vhost",
#                               "mod_evhost",
#                               "mod_userdir",
#                               "mod_cgi",
#                               "mod_compress",
#                               "mod_ssi",
#                               "mod_usertrack",
#                               "mod_expire",
#                               "mod_secdownload",
                                "mod_rrdtool",
                                "mod_accesslog" )
.
.
.
#### rrdtool
rrdtool.binary             = "/usr/bin/rrdtool"
rrdtool.db-name            = "/srv/www/lighttpd.rrd"
  • vim /root/bin/rrdtool-graph.sh
#!/bin/sh
 
RRDTOOL=/usr/bin/rrdtool
OUTDIR=/srv/www/htdocs/rrd
INFILE=/srv/www/lighttpd.rrd
OUTPRE=lighttpd-traffic
 
DISP="DEF:bin=$INFILE:InOctets:AVERAGE \
      DEF:binmin=$INFILE:InOctets:MIN \
      DEF:binmax=$INFILE:InOctets:MAX \
      DEF:bout=$INFILE:OutOctets:AVERAGE \
      DEF:boutmin=$INFILE:OutOctets:MIN \
      DEF:boutmax=$INFILE:OutOctets:MAX \
      LINE1:bin#0000FF:in \
      LINE1:binmin#2222FF: \
      STACK:binmax#2222FF: \
      LINE1:bout#FF0000:out \
      LINE1:boutmin#FF2222: \
      STACK:boutmax#FF2222: \
      -v bytes/s"
 
$RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP
$RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP
$RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP
 
OUTPRE=lighttpd-requests
 
DISP="DEF:req=$INFILE:Requests:AVERAGE \
      DEF:reqmin=$INFILE:Requests:MIN \
      DEF:reqmax=$INFILE:Requests:MAX \
      LINE1:req#0000FF:requests \
      LINE1:reqmin#2222FF: \
      STACK:reqmax#2222FF: \
      -v req/s"
 
$RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP
$RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP
$RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP

Crontab einrichten

Aller 15 Minuten ausführen:

  • vim /etc/crontab
# user defined cronjobs
*/15    * * * * root    /root/bin/rrdtool-graph.sh >/dev/null 2>&1

Index Seite erstellen

  • vim /srv/www/htdocs/rrd/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Lighttpd Statistics</title>
</head>
<body>
<h1>Lighttpd Statistics</h1>
<table border="0" cellpadding="1" cellspacing="1">
  <tr>
    <td><img src="lighttpd-requests-day.png" alt="lighttpd-requests-day.png"><br /><font size="-2">Lighttpd requests per day</font></td>
    <td><img src="lighttpd-requests-hour.png" alt="lighttpd-requests-hour.png"><br /><font size="-2">Lighttpd requests per hour</font></td>
  </tr>
  <tr>
    <td><img src="lighttpd-requests-month.png" alt="lighttpd-requests-month.png"><br /><font size="-2">Lighttpd requests per month</font></td>
    <td><br /></td>
  </tr>
  <tr>
    <td><img src="lighttpd-traffic-day.png" alt="lighttpd-traffic-day.png"><br /><font size="-2">Lighttpd traffic per day</font></td>
    <td><img src="lighttpd-traffic-hour.png" alt="lighttpd-traffic-hour.png"><br /><font size="-2">Lighttpd traffic per hour</font></td>
  </tr>
  <tr>
    <td><img src="lighttpd-traffic-month.png" alt="lighttpd-traffic-month.png"><br /><font size="-2">Lighttpd traffic per month</font></td>
    <td><br /></td>
  </tr>
</table>
</body>
</html>

Ressourcen:

lighttpd.txt · Zuletzt geändert: 2011/07/22 23:26 (Externe Bearbeitung)
 
Falls nicht anders bezeichnet, ist der Inhalt dieses Wikis unter der folgenden Lizenz veröffentlicht: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki