hunterx Posted July 11, 2011 Share Posted July 11, 2011 Hello everyone, I would like to know if it is possible to restart the Linux server using PHP script? In related to changing IP Address from Static to DHCP, I need to reboot the system so that it will take effect. i tried this code: system("/usr/bin/reboot"); error message is : reboot: must be useruser system('/etc/init.d/network restart'); the error is: Shutting down loopback interface: [FAILED] Bringing up loopback interface: [FAILED] Hope you can help me in this. Thank you! Regards to all. Link to comment https://forums.phpfreaks.com/topic/241647-linux-server-reboot-in-php-script/ Share on other sites More sharing options...
trq Posted July 11, 2011 Share Posted July 11, 2011 Your server needs permission enough to execute these commands. I suggest you have a look at sudo. Link to comment https://forums.phpfreaks.com/topic/241647-linux-server-reboot-in-php-script/#findComment-1241149 Share on other sites More sharing options...
hunterx Posted July 11, 2011 Author Share Posted July 11, 2011 Thank you for reply... I am newbie in Linux...how can I apply sudo in my PHP script? do you have any suggestion? Link to comment https://forums.phpfreaks.com/topic/241647-linux-server-reboot-in-php-script/#findComment-1241260 Share on other sites More sharing options...
trq Posted July 12, 2011 Share Posted July 12, 2011 Executing the sudo command in php is the easy part, configuring sudo is where it gets complicated. Sudo allows you to let specific users and/or group execute specific commands as the root user. This is all configurable within the /etc/sudoers file which should only be edited via sudoedit. This has nothing at all to do with php. Link to comment https://forums.phpfreaks.com/topic/241647-linux-server-reboot-in-php-script/#findComment-1241648 Share on other sites More sharing options...
AyKay47 Posted July 12, 2011 Share Posted July 12, 2011 A word of caution, if you are going to tamper with the directory that thorpe pointed out, study on how to edit this correctly before beginning, as tampering with this directory ignorantly can mess with a lot of important settings Link to comment https://forums.phpfreaks.com/topic/241647-linux-server-reboot-in-php-script/#findComment-1241651 Share on other sites More sharing options...
trq Posted July 12, 2011 Share Posted July 12, 2011 A word of caution, if you are going to tamper with the directory that thorpe pointed out, study on how to edit this correctly before beginning, as tampering with this directory ignorantly can mess with a lot of important settings It's a file, not a directory. And yeah, as noted, it needs to be edited using sudoedit. Link to comment https://forums.phpfreaks.com/topic/241647-linux-server-reboot-in-php-script/#findComment-1241654 Share on other sites More sharing options...
AyKay47 Posted July 12, 2011 Share Posted July 12, 2011 yeah file, sorry it's been a long day. When I first started coding I messed with this file prematurely, man was that a bad time for me... :'( yes you did specify that thorpe, just read more thoroughly, my apologies Link to comment https://forums.phpfreaks.com/topic/241647-linux-server-reboot-in-php-script/#findComment-1241657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.