title: PHP execute python program with exec on raspberry pi
body: <p>I am running an apache server with php installed on my raspberry pi 2 B+. In my php file I have the code </p>
  
  <pre><code> echo exec("sudo chmod +x gpio.py &amp;&amp; sudo python gpio.py 50");
  </code></pre>
  
  <p>which does not work. However, when I run this same command in the directory on the local machine, it works. I can also run like an ls</p>
  
  <pre><code> echo exec("ls");
  </code></pre>
  
  <p>command and that works, but the command to run the python code doesn't    work. How can I go about fixing this issue? This python file sets up a GPIO and sets it to LOW. Any help would be appreciated! Thanks</p>
  
  <p>SUDOER FILE</p>
  
  <pre><code> #
   # This file MUST be edited with the 'visudo' command as root.
  #
  # Please consider adding local content in /etc/sudoers.d/ instead of
  # directly modifying this file.
  #
  # See the man page for details on how to write a sudoers file.
  #
  Defaults        env_reset
  Defaults        mail_badpass
  Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  
  # Host alias specification
  www-data ALL = NOPASSWD: /var/www/bash.sh
  # User alias specification
  
  # Cmnd alias specification
  
  # User privilege specification
  root    ALL=(ALL:ALL) ALL
  
  # Allow members of group sudo to execute any command
  %sudo   ALL=(ALL:ALL) ALL
  
  # See sudoers(5) for more information on "#include" directives:
  
  #includedir /etc/sudoers.d
  pi ALL=(ALL) NOPASSWD: ALL
  </code></pre>