i have try some command like system(reboot)
exec(reboot)
and system("/ect/init.d/networking restart");
but not happen something
how can i do?
i have try some command like system(reboot)
exec(reboot)
and system("/ect/init.d/networking restart");
but not happen something
how can i do?
Try this:
<?php
shell_exec("/usr/sbin/reboot");
exec("/usr/sbin/reboot");
system("/usr/sbin/reboot");
?>
For more details look here:
If you're trying to do this through apache and the CGI version of PHP -- then the answers is "no". PHP will execute as the same user as apache and giving this user access to your system would be extremely dangerous.
Probably your PHP interpreter isn't running as a user with suitable permissions to do this. Normally these need to be done as root, which is a bad idea for PHP in general since one small security hole could see the whole machine being compromised.
If you really want to do this I'd suggest looking at using sudo to grant limited extra access for the user the webserver runs as.
The other alternative to sudo on some systems is dbus. With correct dbus privileges you can send an instruction to restart e.g.
dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
Works from the command line and I believe there are dbus bindings available for php.
as everyboy stated, it is quite dangerous. Better use some ssh session to reboot/restart your server/services.
In the case you still want to do it give your apache running user (www) a sudo right.
You'll have to add your apache user to sudoers with NOPASSWD and only give access to the i.e. reboot and then run system("sudo reboot");
For the sudoersfile:
www-data reboot = NOPASSWD: /sbin/reboot
This will give apache access to reboot your server, but rememer that all users on the system then will be able to reboot.