首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决$DAEMON -t $DAEMON_OPT权限被拒绝的问题?

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

Stack Overflow用户
提问于 2014-11-08 23:51:08
回答 1查看 1.4K关注 0票数 0

I在ubuntu服务器14.04上配置nginx + meteor,地址是:http://www.andrehonsberg.com/article/install-nginx-141-meteor-js-websocket-ubuntu-1204

但是当: service nginx start时,我得到了失败:

代码语言:javascript
复制
service nginx start
Starting nginx: /etc/init.d/nginx: 26: /etc/init.d/nginx: /usr/sbin/nginx: Permission denied

这是我的nginx init脚本:

代码语言:javascript
复制
#!/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_OPT

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

EN

回答 1

Stack Overflow用户

发布于 2015-10-16 19:58:10

只要你在你的服务器上是root/sudo,你现在在Azure上就不会面临这样的问题。

当你在azure的ubuntu上安装nginx时,仍然存在启动启动的问题。

为了在安装后启动它,我必须强制重新创建整个链接( -f是强制的):

代码语言:javascript
复制
update-rc.d  -f nginx remove
update-rc.d  -f nginx defaults

我仍然想知道为什么..

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26818964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档