title: How to execute a shell script in PHP?
body: <p>I have a script in <em>/var/www/myscript.sh</em> which creates folders and runs the command <code>svn update</code> for my projects. I need to execute this script by calling it in a PHP file in the browser (i.e. <em>Localhost/test.php</em>). I tried using functions <code>shell_exec()</code> and <code>exec()</code> but those did not work. I ran my shell script in terminal with <code>su www-data &amp;&amp; ./myscript.sh</code> and it worked. What else am I missing?</p>
  <pre><code>&lt;?php
  $output = shell_exec(&quot;./myscript.sh&quot;);
  ?&gt;
  </code></pre>
  <hr />
  <h3>Update 5/4/2011:</h3>
  <p>I added <code>www-data ALL=(ALL) NOPASSWD:ALL</code> to /etc/sudoers and it works, but this is very insecure. Is there another way to do this?</p>