Cygwin 下 lighttpd 安装纪录
Wednesday, 11. July 2007, 05:00:17
用cygwin的setup,选择组件lighttpd即可完成安装。
创建log路径
$ mkdir /var/log/lighttpd
$ chown :Users /var/log/lighttpd
修改config文件
$ cd /etc/lighttpd/
$ cp lighttpd.conf.default lighttpd.conf
$ chown :Users lighttpd.conf
$ vi lighttpd.conf
主要是修改几个路径:
server.document-root = "/srv/www/htdocs/" server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" accesslog.filename = "/var/log/lighttpd/access.log"
其他根据自己需要调整。
创建启动/停止脚本
$ vi /etc/rc.d/init.d/lighttpd
内容如下:
#!/bin/sh
#
# lighttpd Startup script for the lighttpd server with cygwin
#
# chkconfig: - 85 15
# description: Lightning fast webserver with light system requirements
#
# processname: lighttpd
# config: /etc/lighttpd/lighttpd.conf
# 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 [ -z "$CONF_PATH" ]; then
CONF_PATH="/etc/lighttpd/lighttpd.conf"
fi
APPNAME="lighttpd"
APPPATH="/usr/sbin/lighttpd"
PIDFILE="/var/run/lighttpd.pid"
RETVAL=0
start() {
echo -n $"Starting $APPNAME: "
$APPPATH -f $CONF_PATH
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $APPNAME: "
kill `cat $PIDFILE`
RETVAL=$?
echo
return $RETVAL
}
reload() {
echo -n $"Reloading $APPNAME: "
kill -HUP `cat $PIDFILE`
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|restart|reload}"
RETVAL=1
esac
exit $RETVAL
在我的机器上,以上文件要保存成Unix格式(LF换行),不然会出错(有点奇怪)。
$ chown :Users /etc/rc.d/init.d/lighttpd
$ chmod a+x /etc/rc.d/init.d/lighttpd
启动/停止测试
$ /etc/rc.d/init.d/lighttpd start
$ ps -ef | grep lighttpd
$ /etc/rc.d/init.d/lighttpd reload
$ ps -ef | grep lighttpd
$ /etc/rc.d/init.d/lighttpd stop
$ ps -ef | grep lighttpd
$ /etc/rc.d/init.d/lighttpd restart
$ ps -ef | grep lighttpd
HTTP测试
打开浏览器,访问
http://localhost/
如能看到网页,即成功。
补充:
在Windows下,或许 lighttpd for windows 用起来会更舒服一些。







