lighttpd的启动脚本

参考http://trac.lighttpd.net/trac/wiki/TutorialInstallation中Installing services部分

为lighttpd增加server的启动

进入lighttpd的安装目录

我的/home/suantop/lighttpd-1.4.19
# sed -e 's/FOO/lighttpd/g' doc/rc.lighttpd.redhat > /etc/init.d/lighttpd

# chmod a+rx /etc/init.d/lighttpd

# cp -p doc/sysconfig.lighttpd /etc/sysconfig/lighttpd

结合自己的环境需要更改/etc/sysconfig/lighttpd

# cat doc/sysconfig.lighttpd 默认的
LIGHTTPD_CONF_PATH=/etc/lighttpd/lighttpd.conf
修改内容如下:
# cd /etc/sysconfig
# vi lighttpd
LIGHTTPD_CONF_PATH=/usr/local/lighttpd/lighttpd.conf

 

再次vi /etc/init.d/lighttpd
说明更改的地方如下
LIGHTTPD_CONF_PATH="/usr/local/lighttpd/lighttpd.conf"
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
其他的默认就可以了# /etc/init.d/lighttpd restart
停止 lighttpd:[确定]
启动 lighttpd:[确定]

具体的lighttpd的内如如下:

#!/bin/sh
#
# lighttpd     Startup script for the lighttpd server
#
# chkconfig: - 85 15
# description: Lightning fast webserver with light system requirements
#
# processname: lighttpd
# config: /etc/lighttpd/lighttpd.conf
# config: /etc/sysconfig/lighttpd
# pidfile: /var/run/lighttpd.pid
#
# Note: pidfile is assumed to be created
# by lighttpd (config: server.pid-file).
# If not, uncomment 'pidof' line.

# Source function library
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/lighttpd ]; then
        . /etc/sysconfig/lighttpd
fi

if [ -z "$LIGHTTPD_CONF_PATH" ]; then
        LIGHTTPD_CONF_PATH="/usr/local/lighttpd/lighttpd.conf"
fi

prog="lighttpd"
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        daemon $lighttpd -f $LIGHTTPD_CONF_PATH
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc $lighttpd
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

reload() {
        echo -n $"Reloading $prog: "
        killproc $lighttpd -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -f /var/lock/subsys/$prog ]; then
                        stop
                        start
                fi
                ;;
        reload)
                reload
                ;;
        status)
                status $lighttpd
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
                RETVAL=1
esac

exit $RETVAL

你可能感兴趣的:(linux,lighttpd,脚本,RedHat,F#,.net)