Jump to content

Linux Server reboot in PHP script


hunterx

Recommended Posts

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

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.

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.