Restart nginx without sudo?

前端 未结 3 924
攒了一身酷
攒了一身酷 2021-01-30 05:42

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

3条回答
  •  孤独总比滥情好
    2021-01-30 06:13

    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.

    Add this to the /etc/sudoers file

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

    Write script as root

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

    Make the script executable

    Test.

    sudo /path/to/script
    

提交回复
热议问题