title: How can I have a PHP script run a shell script as root?
body: <p>Running Fedora 9/10, Apache 2, PHP 5...</p>
  
  <p>Can I run a shell script as root, from a PHP script using exec()?</p>
  
  <p>Do I just give Apache root priveleges, and then add "sudo" in front of them command?</p>
  
  <p>Specifically, I'm trying to start and stop a background script.</p>
  
  <p>Currently I have a shell script that just runs the app, start.sh:</p>
  
  <pre><code>#!/bin/bash 
  /path/to/my/app/appname
  </code></pre>
  
  <p>And a script that kills the app, stop.sh:</p>
  
  <pre><code>#!/bin/bash 
  killall appname
  </code></pre>
  
  <p>Would I just do:</p>
  
  <pre><code>&lt;?php
  exec("sudo start.sh");
  ?&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>