Ubuntu 如何解决$DAEMON-t$DAEMON_OPT权限被拒绝的问题?

Ubuntu 如何解决$DAEMON-t$DAEMON_OPT权限被拒绝的问题?,ubuntu,azure,nginx,Ubuntu,Azure,Nginx,我在ubuntu服务器14.04上配置nginx+meteor 发件人: 但我在以下情况下失败:服务nginx启动: service nginx start Starting nginx: /etc/init.d/nginx: 26: /etc/init.d/nginx: /usr/sbin/nginx: Permission denied 这是我的nginx init脚本: #!/bin/sh ### BEGIN INIT INFO # Provides: nginx #

我在ubuntu服务器14.04上配置nginx+meteor 发件人:

但我在以下情况下失败:服务nginx启动:

service nginx start
Starting nginx: /etc/init.d/nginx: 26: /etc/init.d/nginx: /usr/sbin/nginx: Permission denied
这是我的nginx init脚本:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/nginx
NAME=nginx
DESC=nginx
# Include nginx default if available
if [ -f /etc/default/nginx ]; then
  . /etc/default/nginx
fi
test -x $DAEMON || exit 0
set -e
. /lib/lsb/init-functions
test_nginx_config() {
    if $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1; then
        return 0
    else
        $DAEMON -t $DAEMON_OPTS
        return $?
    fi
}
case "$1" in
    start)
        echo -n "Starting $DESC: "
        test_nginx_config
        # Check if the ULIMIT is set in /etc/default/nginx
        if [ -n "$ULIMIT" ]; then
            # Set the ulimits
            ulimit $ULIMIT
        fi
        start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
            --exec $DAEMON -- $DAEMON_OPTS || true
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
            --exec $DAEMON || true
        echo "$NAME."
        ;;
    restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
            /var/run/$NAME.pid --exec $DAEMON || true
        sleep 1
        test_nginx_config
        # Check if the ULIMIT is set in /etc/default/nginx
        if [ -n "$ULIMIT" ]; then
            # Set the ulimits
            ulimit $ULIMIT
        fi
        start-stop-daemon --start --quiet --pidfile \
            /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
        echo "$NAME."
        ;;
    reload)
        echo -n "Reloading $DESC configuration: "
        test_nginx_config
        start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
            --exec $DAEMON || true
        echo "$NAME."
        ;;
    configtest|testconfig)
        echo -n "Testing $DESC configuration: "
        if test_nginx_config; then
            echo "$NAME."
        else
            exit $?
        fi
        ;;
    status)
        status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
        ;;
    *)
        echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
        exit 1
        ;;
esac
exit 0
第26行是:$DAEMON-t$DAEMON\u OPT

我使用azure,所以我不能使用su,我只能使用sudo,但仍然失败。
如何解决这个问题?

只要您是服务器上的root/sudo,您现在就不可能在Azure上遇到这样的问题

在azure的ubuntu上安装nginx后,启动时的引导仍然存在一个持久的问题

要在安装后启动它,我必须强制执行整个链接(必须使用-f):

我还在想为什么

update-rc.d  -f nginx remove
update-rc.d  -f nginx defaults