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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.