重新启动没有sudo的nginx? [英] Restart nginx without sudo?

查看:159
本文介绍了重新启动没有sudo的nginx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想能够上限:部署而不必键入任何密码。我已经设置了所有的私钥,所以我可以得到远程服务器的罚款,现在使用svn在ssh,所以没有密码在那里。

So I want to be able to cap:deploy without having to type any passwords. I have setup all private keys so I can get to the remote servers fine, and am now using svn over ssh, so no passwords there.

我有一个最后一个问题,我需要能够重新启动nginx。现在我有sudo /etc/init.d/nginx重新加载。这是一个问题b / c它使用capistrano密码,我刚刚删除b / c我正在使用密钥。任何关于如何重新启动nginx的想法w?输入密码?

I have one last problem, I need to be able to restart nginx. Right now I have sudo /etc/init.d/nginx reload. That is a problem b/c it uses the capistrano password, the one I just removed b/c I am using keys. Any ideas on how to restart nginx w\out a password?

推荐答案

我刚刚花了一个小时看着sudoer通配符,就像试图解决这个确切的问题。实际上,你真正需要的是一个可重新启动nginx的根脚本。

I just spent a good hour looking at sudoer wildcards and the like trying to solve this exact problem. In truth, all you really need is a root executable script that restarts nginx.

将它添加到/ etc / sudoers文件中

Add this to the /etc/sudoers file

username hostname ALL=NOPASSWD: /path/to/script

以root身份写脚本

#! /bin/bash
/bin/kill -HUP `cat /var/run/nginx.pid`

使脚本可执行

测试。

sudo /path/to/script

这篇关于重新启动没有sudo的nginx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆