Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.