what is the best way to run shell script (with root privilege) via php?
I've made a simple bash script for 开发者_如何学Pythonserver admininstration and I cannot figure how can I run it in safely inside a php page: I'd like to create a php admininstration page but I obviously don't want to hard-code root password anyware. Let's make an example (this is a foo script, of course)
#!/bin/bash
touch /$1
this simple/stupid script will not work if the user who run it as no writing permission on /.
Actually the script add apache virtualhosts, ftp users and so on... any ideas? thanksUse
sudo /path/to/executable/file
and set up sudo
so it can execute the following command for the current user as a root.
http://www.sudo.ws/sudo/sudoers.man.html - here is the sudoers manual, the configuration file, that you have to modify.
zerkms ALL = (ALL) NOPASSWD: /sbin/iptables -L FORWARD -n -v -x
This is example from my /etc/sudoers
. Here I allowed to run command /sbin/iptables -L FORWARD -n -v -x
as root
without asking a password for user zerkms
.
精彩评论