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"));
?>