本文介绍了从CGI脚本重新启动服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试让apache运行cgi剥离命令
Im am trying to get a cgi stript run by apache to command
service network restart
我只是将命令放在bash文件中,但是出现了权限被拒绝的错误.
I just put the command in a bash file but I get a permission denied error.
#!/bin/bash
service network restart
也许我需要一个perl解决方案?
Maybe I need a perl solution?
推荐答案
您可以在sudoers
中添加一条规则,以让您的CGI脚本以root身份运行该脚本(而不执行其他操作).使用sudo visudo
编辑sudoers
来添加以下行:
You could add a rule in sudoers
to let your CGI scripts run the script (and nothing else) as root. Edit sudoers
using sudo visudo
to add this line:
apache ALL = NOPASSWD: /path/to/script.sh
然后您的CGI脚本无需输入密码就可以执行sudo service network restart
.
And then your CGI script will be able to do sudo service network restart
without entering password.
这篇关于从CGI脚本重新启动服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!