After opening and reading each result on Google, I decided it was time to make my own thread. I am sorry that I need to ask a question that has already been asked before, I canβt stress it enough, but I have no other choice, since no other question asked has helped me achieve my goal.
I am trying to configure a tool to reboot / execute other system functions through a web interface supported by HTML (for buttons / text) and PHP (for performing the above functions).
I can't get this to work. I read that I need to add the user to the sudoers file, and I tried. I am running Nginx on my server, how to add a user to sudoers in my case?
In addition, I know about security threats.
The following is the following:
HTML (index.html):
<body> <h3>Restart</h3> <p> <form action="restart.php" method="get"> <input type="submit" value="Press me."> </form> </p> </body>
PHP (restart.php):
<?php echo "This is a test"; echo "<br>"; echo "<br>"; echo shell_exec('ifconfig'); echo "<br>"; echo "<br>"; echo "Restarting server..."; exec ('/usr/bin/sudo /etc/init.d/portmap restart'); shell_exec("/sbin/reboot"); exec("/sbin/reboot"); system("/sbin/reboot"); ?>
Keep in mind that here, I only have so many things that they are trying to accomplish, so I make sure to hit the target when one of them works, if that makes sense. IFConfig is just a test to make sure that it is truly capable of performing.
Sudoers:
All this on Ubuntu 14.04 LEMP.
source share