title: Running Python script from Apache server using PHP
body: <p>I'm working on a project with a raspberry pi to turn on and off an LED strip using a mobile device.</p>
  
  <p>The last issue I'm running into is getting the scripts to run from the apache server being hosted on the raspberry pi.</p>
  
  <pre><code>&lt;html&gt;
     &lt;head&gt;
        &lt;meta charset="UTF-8" /&gt;
        &lt;link rel="stylesheet" type="text/css" href="css/style.css"&gt;
     &lt;/head&gt;
     &lt;?php
        if (isset($_POST['LightON'])) {
            exec("sudo python /home/pi/lightOn.py");
        }
        if (isset($_POST['LightOFF'])) {
            exec("sudo python /home/pi/lightOff.py");
        }
     ?&gt;
     &lt;form method="post"&gt;
        &lt;button class="btn" name="LightON"&gt;Light ON&lt;/button&gt;&amp;nbsp;
        &lt;button class="btn" name="LightOFF"&gt;Light OFF&lt;/button&gt;&lt;br&gt;&lt;br&gt;
     &lt;/form&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The Python script works perfectly when being run out of the command line on the raspberry pi. But when run on the apache server, nothing happens. What am I doing wrong here? Does it have something to do with permissions? I'm very new to linux and php, please keep that in mind.</p>
  
  <p>Why does the Python work locally but not on the server?</p>
  
  <p>Thanks!</p>