How can I use sudo to reboot my server using php?
<p>I've tried these:</p>

<pre><code>&lt;?php
  $r = shell_exec('sudo -u root -S /etc/init.d/apache2 restart &lt; /home/$user/passfile');
  echo $rin;
?&gt;
</code></pre>

<p>(password on passfile) DIDNT GET</p>

<pre><code>&lt;?php
  (php$output4=shell_exec('echo "$x" | whoami 1&gt;/dev/null &amp;&amp; sudo /etc/init.d/ssh restart');
?&gt;
</code></pre>



<pre><code>&lt;html&gt;
  &lt;body&gt;
    &lt;script type="text/javascript"&gt;
      x=prompt("entr");
    &lt;/script&gt;
  &lt;body&gt;
&lt;/html&gt;
</code></pre>



<pre><code>&lt;html&gt;
  &lt;form id="form1" name="form1" method="post" action=""&gt;
    &lt;input type="submit" name="b1" value="click"  /&gt;
  &lt;/form&gt;
&lt;/html&gt;
</code></pre>



<pre><code>&lt;?php
  if(isset($_POST['b1'])) {
    echo "&lt;pre&gt;$output4&lt;/pre&gt;";
  }

?&gt;
</code></pre>

<p>Please help.</p>
