Lighttpd 未干净重启(地址已被使用)

Lighttpd 未干净重启(地址已被使用)

最近在进行 dist-upgrade 时,我安装在 Ubuntu 8.0.4 上的 lighttpd-1.4.19 开始无法使用 /etc/init.d/lighttpd restart 命令正确重新启动或重新加载。

~$ sudo /etc/init.d/lighttpd restart
 * Stopping web server lighttpd
   ...done.
 * Starting web server lighttpd
2009-06-13 04:06:36: (network.c.300) can't bind to port:  80 Address already in use 
   ...fail!

当我重新加载时会出现同样的错误。

我解决这个问题的方法是杀死 lighttpd,然后发出启动命令,但似乎我不应该这样做:)

我查看了我的配置文件,没有发现任何直接错误。有人知道是什么导致了这个错误吗?这似乎是撰写此问题时可通过 apt-get 路径获得的最新版本。

我的配置文件是:

# Debian lighttpd configuration file
# 

############ Options you really have to take care of ####################

## modules to load
# mod_access, mod_accesslog and mod_alias are loaded by default
# all other module should only be loaded if neccesary
# - saves some time
# - saves memory

server.modules              = ( 
            "mod_access",
            "mod_alias",
            "mod_accesslog",
            "mod_compress",
            "mod_fastcgi",
            "mod_rewrite", 
            "mod_redirect", 
 )

## a static document-root, for virtual-hosting take look at the 
## server.virtual-* options
server.document-root       = "/var/www/"

## where to send error-messages to
server.errorlog            = "/var/log/lighttpd/error.log"

fastcgi.server = (".php" => ((
  "bin-path" => "/usr/bin/php5-cgi",
  "socket" => "/tmp/php.socket"
)))   

## files to check for if .../ is requested
index-file.names           = ( "index.php", "index.html",
                               "index.htm", "default.htm",
                               "index.lighttpd.html" )


## Use the "Content-Type" extended attribute to obtain mime type if possible
# mimetype.use-xattr = "enable"

#### accesslog module
accesslog.filename         = "/var/log/lighttpd/access.log"

## deny access the file-extensions
#
# ~    is for backupfiles from vi, emacs, joe, ...
# .inc is often used for code includes which should in general not be part
#      of the document-root
url.access-deny            = ( "~", ".inc" )

##
# which extensions should not be handle via static-file transfer
#
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "audio/x-wav",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".rss"          =>      "application/rss+xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
 )

include_shell "/usr/share/lighttpd/include-conf-enabled.pl" 

我的 /etc/init.d/lighttpd 脚本是(安装后未发生任何变化):

#!/bin/sh
### BEGIN INIT INFO
# Provides:          lighttpd
# Required-Start:    networking
# Required-Stop:     networking
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the lighttpd web server.
### END INIT INFO


PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/lighttpd
NAME=lighttpd
DESC="web server"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
SSD="/sbin/start-stop-daemon"

DAEMON_OPTS="-f /etc/lighttpd/lighttpd.conf"

test -x $DAEMON || exit 0

set -e

# be sure there is a /var/run/lighttpd, even with tmpfs
mkdir -p /var/run/lighttpd > /dev/null 2> /dev/null
chown www-data:www-data /var/run/lighttpd
chmod 0750 /var/run/lighttpd

. /lib/lsb/init-functions

case "$1" in
  start)
    log_daemon_msg "Starting $DESC" $NAME
    if ! $ENV $SSD --start --quiet\
    --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
            log_end_msg 1
    else
            log_end_msg 0
    fi
    ;;
  stop)
    log_daemon_msg "Stopping $DESC" $NAME
    if $SSD --quiet --stop --oknodo --retry 30\
    --pidfile $PIDFILE --exec $DAEMON; then
        rm -f $PIDFILE
        log_end_msg 0
    else
        log_end_msg 1
    fi
    ;;
  reload)
    log_daemon_msg "Reloading $DESC configuration" $NAME
    if $SSD --stop --signal 2 --oknodo --retry 30\
    --quiet --pidfile $PIDFILE --exec $DAEMON; then
        if $ENV $SSD --start --quiet  \
        --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
        log_end_msg 0
        else
        log_end_msg 1
        fi
    else
        log_end_msg 1
    fi
  ;;
  restart|force-reload)
    $0 stop
    [ -r  $PIDFILE ] && while pidof lighttpd |\
         grep -q `cat $PIDFILE 2>/dev/null` 2>/dev/null ; do sleep 1; done
    $0 start
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    exit 1
    ;;
esac

exit 0

答案1

听起来你的“停止”脚本实际上并没有干净地停止服务器。

您可以发布您的 /etc/init.d/lighttpd 文件吗?

答案2

好的,有时,当您安装 php5-mysql 或 php5-gd 时,它会自动安装 apache2(因为 Debian 的软件包依赖性)

尝试top查看 apache 是否没有启动。

如果已安装:尝试“apt-get remove apache2*”

之后应该没问题

(对不起,我的英语不好)

答案3

在 apt-get 升级之后,我遇到了这个问题。查看我的 strace 输出,第一次绑定到端口 80 成功。然后当尝试将 ipv6 绑定到同一端口时,失败了。所以我注释掉了以下行:

#include_shell "/usr/share/lighttpd/use-ipv6.pl"

现在它又能正常工作了。

相关内容