Forum Moderators: coopster
I have tried the exec command, but this doesn't seem to work...
e.g.
exec("/etc/init.d/dhcpd stop",$report)
Have you checked your logs? It may be likely that the user PHP is running as does not have permission to start/stop the daemon ...
[php.net...]
I thought it might be a security issue so have been experimenting to try and discover what is what.
I tried running whoami command via the system command, and it told me it was using 'wwwrun' as the user. So thought, ok, if I configure 'sudo' so that no password is required, and wwwrun has the same rights as root then it should work.
So I tried...
system("sudo service dhcpd stop");
And set the following entry in the sudoers config file...
wwwrun ALL = (root) ALL
This still hasn't worked. I've looked on the link you have sent, and it mentions that apache uses the nobody user, so I will attempt the same thing with this user and see what happens.
If any one can give me any other pointers it would be most appreciated.
I have managed to get it to work, it is the nobody user that needs to be added to the sudoers file..
e.g.
nobodyALL = (root) NOPASSWD: ALL
This is probably not a secure way of configuring it, but for test purposes at least I know that security is the cause of my problems!
If anyone has a better way of doing this however please let me know.