title: Some of my Python scripts are not working on PHP
body: <p>I'm setting up a Apache 2, PHP 7, Python 3.6.3 on my Raspberry pi (Ubuntu)
  I want execute Python script using PHP.</p>
  
  <p>I've tried execute below code, but it does not work.</p>
  
  <p>This is my body tag.</p>
  
  <p><strong>con_LED.php:</strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;form method="post"&gt;
      &lt;button name="LightON" value="on"&gt;LightON&lt;/button&gt; 
      &lt;/form&gt;
  
      &lt;form method="post"&gt;
      &lt;button name="LightOFF" value="off"&gt;LightOFF&lt;/button&gt; 
  
      &lt;/form&gt;
      &lt;p&gt;&lt;/p&gt;
  
      &lt;?php
      if (isset($_POST["LightON"])) {
      exec("python3 /var/www/html/LEDON.py", $output, $var);
      print_r($output."&lt;br&gt;");
      print_r($var);
      }
  
      if (isset($_POST["LightOFF"])) {
      exec("python3 /var/www/html/LEDOFF.py");
      print_r($output);
      print_r($var);
      }
      ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I did some some troubleshooting.
  To check, I replace my code to:</p>
  
  <pre><code>exec("ls -al", $output, $var)
  </code></pre>
  
  <p>Which works.</p>
  
  <p>I also made:</p>
  
  <p><strong>a.py:</strong></p>
  
  <pre><code>with open("t1.txt","a") as f:
      f.write("Heelo\n")
  </code></pre>
  
  <p>And executed:</p>
  
  <pre><code>exec("python3 /var/www/html/a.py", $output, $var);
  </code></pre>
  
  <p>This also works (meaning I can see <code>t1.txt</code> file on my server).</p>
  
  <p>My project is using con_LED.php code to turn the LED on and off.
  But my code isn't working.</p>
  
  <p>Of course, I also tried this code directly on shell, which is working.<br>
  Does anyone know what my problem is?</p>