0

I have an apache2 webserver running on the pi. I have a php file that uses exec() to run a python script. Everything works well from the command line. when loaded through the browser, the exec() function returns nothing. The python script works when executed using sudo -u www-data. php file.php also works from the terminal, but not through the browser. When i try sudo -u www-data php file.php, it asks for the password, which i didnt set. What should I do? Here is the output of ls -l command.

-rwxrwxrwx 1 www-data www-data   125 Jul  2 19:52 test.php
-rwxr-x--- 1 www-data www-data   218 Jul  2 19:44 lights.py

THE PHP FILE

<?php
ini_set('DISPLAY_ERRORS',1);
echo(shell_exec("/usr/bin/python3 /var/www/html/control/lights.py"));
?>
2
  • determine if the python script gets called by PHP Commented Jul 2, 2019 at 16:27
  • Have you added the www-data user to the GPIO group? What shows up in /var/log/apache2/error.log when the script fails? Commented Jul 2, 2019 at 19:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.